c++-gtk-utils
|
A scoped locking class for exception safe RWLock write locking which tracks the status of its read-write lock.. More...
#include <c++-gtk-utils/rw_lock.h>
Public Member Functions | |
int | lock () |
int | trylock () |
int | unlock () |
bool | is_owner () const |
WriterTrackLock (RWLock &rw_lock_) | |
WriterTrackLock (RWLock &rw_lock_, Locked tag) | |
WriterTrackLock (RWLock &rw_lock_, DeferLock tag) | |
~WriterTrackLock () | |
A scoped locking class for exception safe RWLock write locking which tracks the status of its read-write lock..
This class is similar to a RWLock::WriterLock object, except that it tracks whether the read-write lock it manages is locked for writing by the thread creating the RWLock::WriterTrackLock object (provided that, while the RWLock::WriterTrackLock object exists, the thread creating it only accesses the managed read-write lock for write-locking through that object). This enables RWLock::WriterTrackLock::unlock() to be used without it being followed later by a call to RWLock::WriterTrackLock::lock() or a successful call to RWLock::WriterTrackLock::trylock(), and also permits locking to be deferred until after construction of the RWLock::WriterTrackLock object. Note that only one thread may call the methods of any one RWLock::WriterTrackLock object, including causing its destructor to be invoked.
|
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
This constructor defers locking of the read-write lock for writing until an explicit call to lock() or trylock() is made. 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::defer enum tag to this parameter. |
Since 1.2.1
|
inline |
The destructor unlocks the read-write lock which is managed for writing if it is owned by this RWLock::WriterTrackLock object. It is not a cancellation point. It does not throw.
Since 1.2.1
|
inline |
Indicates whether the read-write lock managed by this RWLock::ReaderTrackLock object is locked for writing by it and so owned by it. It does not throw.
Since 1.2.1
|
inline |
Calls RWLock::writer_lock(), and so locks the read-write lock for writing and acquires 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::WriterTrackLock::unlock() or this RWLock::WriterTrackLock object has been constructed with the Thread::defer enum tag. 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 acquire 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::WriterTrackLock::unlock() or this RWLock::WriterTrackLock object has been constructed with the Thread::defer enum tag. 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. It will cause is_owner() to return false unless a subsequent call is made to lock() or a subsequent successful call is made to trylock(). It is not a cancellation point. It does not throw.
Since 1.2.1