Apama
10.0.0.2
|
A simple RAII wrapper for SAG_MUTEX_T that locks the specified mutex in its constructor, and guarantees that it will be unlocked when this object goes out of scope unless it has been unlocked already by that point. More...
#include <sag_connectivity_threading.h>
Public Member Functions | |
SAG_LOCK_GUARD (SAG_MUTEX_T &mx) | |
Create a SAG_LOG_GUARD for a particular mutex. More... | |
~SAG_LOCK_GUARD () | |
Destroy this lock guard. More... | |
void | lock () |
Locks the mutex (throws if the mutex is already locked by this lock guard). More... | |
void | unlock () |
Unlocks the mutex (throws if the mutex is already unlocked by this lock guard). More... | |
A simple RAII wrapper for SAG_MUTEX_T that locks the specified mutex in its constructor, and guarantees that it will be unlocked when this object goes out of scope unless it has been unlocked already by that point.
This is safer than relying on explicitly calling unlock() which can lead to hangs if an exception is thrown before the mutex is unlocked.
Note that you should only use this if your compiler is too old to support C++11 threading primitives. On modern compilers you should use std::mutex with either std::lock_guard or std::unique_lock.
|
inline |
Create a SAG_LOG_GUARD for a particular mutex.
Takes the mutex.
|
inline |
Destroy this lock guard.
Releases the mutex if still held.
|
inline |
Locks the mutex (throws if the mutex is already locked by this lock guard).
|
inline |
Unlocks the mutex (throws if the mutex is already unlocked by this lock guard).