Qore Programming Language Reference Manual 1.19.2
|
A helper class for the RWLock class for exception-safe write lock handling. More...
#include <QC_AutoWriteLock.dox.h>
Public Member Methods | |
constructor (RWLock rwl) | |
Creates the AutoWriteLock object based on the RWLock argument passed and immediately calls RWLock::writeLock() More... | |
copy () | |
Throws an exception; objects of this class cannot be copied. More... | |
destructor () | |
Calls RWLock::writeUnlock() on the saved RWLock and destroys the AutoWriteLock object. More... | |
A helper class for the RWLock class for exception-safe write lock handling.
AutoWriteLock objects, when used along with a RWLock object, allow Qore programmers to safely acquire and release a write lock, even if exceptions are thrown or return statements are executed in the block where the AutoWriteLock object is created.
AutoWriteLock objects are helper objects that acquire a write lock for the lifetime of the AutoWriteLock object. For this reason, it is normally only appropriate to assign an AutoWriteLock object to a local variable, so when the local variable goes out of scope, the AutoWriteLock object will be deleted and the write lock will be automatically released.
For example:
Qore::Thread::AutoWriteLock::constructor | ( | RWLock | rwl | ) |
Creates the AutoWriteLock object based on the RWLock argument passed and immediately calls RWLock::writeLock()
The AutoWriteLock object immediately calls RWLock::writeLock() on the RWLock object passed, and saves it so it can be released when the AutoWriteLock object is destroyed.
THREAD-DEADLOCK | A deadlock was detected while trying to acquire the lock |
LOCK-ERROR | RWLock::writeLock() called while already holding the read lock, object deleted in another thread, etc. |
Qore::Thread::AutoWriteLock::copy | ( | ) |
Throws an exception; objects of this class cannot be copied.
AUTOWRITELOCK-COPY-ERROR | objects of this class cannot be copied |
Qore::Thread::AutoWriteLock::destructor | ( | ) |
Calls RWLock::writeUnlock() on the saved RWLock and destroys the AutoWriteLock object.
LOCK-ERROR | RWLock::writeUnlock() called while not holding the write lock, RWLock object deleted in another thread, etc |