c++-gtk-utils
|
A scoped locking class for exception safe RWLock write locking. More...
#include <c++-gtk-utils/rw_lock.h>
Public Member Functions | |
int | lock () |
int | trylock () |
int | unlock () |
WriterLock (RWLock &rw_lock_) | |
WriterLock (RWLock &rw_lock_, Locked tag) | |
~WriterLock () | |
A scoped locking class for exception safe RWLock write locking.
|
inline |
This constructor locks for writing the read-write lock passed to it. It is not a cancellation point. It does not throw.
rw_lock_ | The read-write lock to be locked for writing. |
Since 1.2.1
This constructor takes a read-write lock already locked for writing (say as a result of RWLock::writer_trylock()), and takes ownership of it. It is not a cancellation point. It does not throw.
rw_lock_ | The read-write lock to be managed for writing by this object. |
tag | Pass the Cgu::Thread::locked enum tag to this parameter. |
Since 1.2.1
|
inline |
The destructor unlocks the owned read-write lock. It is not a cancellation point. It does not throw.
Since 1.2.1
|
inline |
Calls RWLock::writer_lock(), and so locks the read-write lock for writing and reacquires ownership. It blocks if the read-write lock is already locked for reading or writing until it becomes free. This method should normally only be called if a previous call has been made to RWLock::WriterLock::unlock() (that is, where the thread owning the RWLock::WriterLock object has temporarily allowed another thread to take the read-write lock concerned for reading or writing). It is not a cancellation point. It does not throw.
Since 1.2.1
|
inline |
Calls RWLock::writer_trylock(), and so tries to lock the read-write lock for writing and reacquire ownership, but returns immediately with value EBUSY if it is already locked for reading or writing. This method should normally only be called if a previous call has been made to RWLock::WriterLock::unlock() (that is, where the thread owning the RWLock::WriterLock object has temporarily allowed another thread to take the read-write lock concerned for reading or writing). It is not a cancellation point. It does not throw.
Since 1.2.1
|
inline |
Calls RWLock::unlock(), and so unlocks a locked read-write lock owned by the calling thread for writing and relinquishes ownership (so temporarily allowing another thread to take the read-write lock). This method should normally only be called if it is to be followed by a call to RWLock::WriterLock::lock() or a successful call to RWLock::WriterLock::trylock() before the RWLock::WriterLock object concerned goes out of scope (otherwise RWLock::WriterLock's destructor will attempt to unlock an already unlocked read-write lock or a read-write lock of which another thread has by then taken ownership - RWLock::WriterLock objects do not maintain state). See RWLock::WriterTrackLock::unlock() for a safe version of this method. It is not a cancellation point. It does not throw.
Since 1.2.1