Qt 4.8
|
The QWriteLocker class is a convenience class that simplifies locking and unlocking read-write locks for write access. More...
#include <qreadwritelock.h>
Public Functions | |
QWriteLocker (QReadWriteLock *readWriteLock) | |
Constructs a QWriteLocker and locks lock for writing. More... | |
QReadWriteLock * | readWriteLock () const |
Returns a pointer to the read-write lock that was passed to the constructor. More... | |
void | relock () |
Relocks an unlocked lock. More... | |
void | unlock () |
Unlocks the lock associated with this locker. More... | |
~QWriteLocker () | |
Destroys the QWriteLocker and unlocks the lock that was passed to the constructor. More... | |
Properties | |
quintptr | q_val |
The QWriteLocker class is a convenience class that simplifies locking and unlocking read-write locks for write access.
The purpose of QWriteLocker (and QReadLocker is to simplify QReadWriteLock locking and unlocking. Locking and unlocking statements or in exception handling code is error-prone and difficult to debug. QWriteLocker can be used in such situations to ensure that the state of the lock is always well-defined.
Here's an example that uses QWriteLocker to lock and unlock a read-write lock for writing:
It is equivalent to the following code:
The QMutexLocker documentation shows examples where the use of a locker object greatly simplifies programming.
Definition at line 133 of file qreadwritelock.h.
|
inline |
Constructs a QWriteLocker and locks lock for writing.
The lock will be unlocked when the QWriteLocker is destroyed. If lock
is zero, QWriteLocker does nothing.
Definition at line 170 of file qreadwritelock.h.
|
inline |
Destroys the QWriteLocker and unlocks the lock that was passed to the constructor.
Definition at line 138 of file qreadwritelock.h.
|
inline |
Returns a pointer to the read-write lock that was passed to the constructor.
Definition at line 161 of file qreadwritelock.h.
|
inline |
Relocks an unlocked lock.
Definition at line 151 of file qreadwritelock.h.
|
inline |
Unlocks the lock associated with this locker.
Definition at line 141 of file qreadwritelock.h.
Referenced by QDeclarativeTypePrivate::init().
|
private |
Definition at line 167 of file qreadwritelock.h.