c++-gtk-utils
|
A scoped locking class for exception safe locking of GStaticRecMutex objects. More...
#include <c++-gtk-utils/mutex.h>
Public Member Functions | |
GStaticRecMutex * | get () const |
GrecmutexLock (GStaticRecMutex &mutex_) | |
GrecmutexLock (GStaticRecMutex &mutex_, Locked tag) | |
~GrecmutexLock () | |
A scoped locking class for exception safe locking of GStaticRecMutex objects.
This class is mainly intended for use where the native pthreads implementation does not support recursive mutexes so Cgu::Thread::RecMutex and Cgu::Thread::RecMutex::Lock cannot be used.
It should be noted that this class is for use with GStaticRecMutex objects, and not the GRecMutex objects available in glib from glib version 2.32. If glib >= 2.32 is installed, it can be assumed that native recursive mutexes and so Cgu::Thread::RecMutex are available, as glib >= 2.32 also uses native recursive mutexes.
Cgu::Thread::GrecmutexLock::GrecmutexLock | ( | GStaticRecMutex & | mutex_ | ) |
This constructor locks the mutex and acquires ownership, and blocks if it is already locked until it becomes free, unless the constructing thread already holds the lock, in which case it increments the lock count and returns immediately. It is not a cancellation point. It does not throw.
mutex_ | The mutex to be locked. |
Since 1.2.0
|
inline |
This constructor takes an already locked mutex (say as a result of g_static_rec_mutex_trylock()), and takes ownership of it. It is not a cancellation point. It does not throw.
mutex_ | The mutex to be managed by this object. |
tag | Pass the Cgu::Thread::locked enum tag to this parameter. |
Since 1.2.0
Cgu::Thread::GrecmutexLock::~GrecmutexLock | ( | ) |
The destructor unlocks the owned mutex, and either relinquishes ownership (if the mutex has not been recursively locked) or decrements the lock count (if it has). It is not a cancellation point. It does not throw.
Since 1.2.0
|
inline |
This method provides access to the GStaticRecMutex object locked by this GrecmutexLock object. It does not throw. It is thread safe.
Since 1.2.0