#include <QThread.h>
QMtxHold simply takes a FX::QMutex or FX::QRWMutex (or pointers to the same) as an argument to its constructor and locks the mutex for you. Hence then when QMtxHold is destructed, the mutex is guaranteed to be freed.
A QMutex or QRWMutex can also be specified via passing a FX::FXPol_lockable policy.
A rarely used other possibility is to pass QMtxHold::UnlockAndRelock as the second argument to the constructor - this unlocks the mutex and relocks it on destruction.
Public Types | |
enum | Flags { LockAndUnlock, UnlockAndRelock, AcceptNullMutex, IsRWMutex, IsLocked, IsRWMutexWrite } |
Public Member Functions | |
FXFORCEINLINE | QMtxHold (const QMutex *m, FXuint _flags=LockAndUnlock) |
FXFORCEINLINE | QMtxHold (const QMutex &m, FXuint _flags=LockAndUnlock) |
FXFORCEINLINE | QMtxHold (const QRWMutex *m, bool write=true, FXuint _flags=LockAndUnlock) |
FXFORCEINLINE | QMtxHold (const QRWMutex &m, bool write=true, FXuint _flags=LockAndUnlock) |
FXFORCEINLINE void | unlock () |
FXFORCEINLINE void | relock () |
FXFORCEINLINE bool | lockLost () const |
enum FX::QMtxHold::Flags |
FXFORCEINLINE FX::QMtxHold::QMtxHold | ( | const QMutex * | m, | |
FXuint | _flags = LockAndUnlock | |||
) | [inline] |
Constructs an instance holding the lock to mutex m.
FXFORCEINLINE FX::QMtxHold::QMtxHold | ( | const QRWMutex * | m, | |
bool | write = true , |
|||
FXuint | _flags = LockAndUnlock | |||
) | [inline] |
Constructs and instance holding the lock to read/write mutex m.
FXFORCEINLINE void FX::QMtxHold::unlock | ( | ) | [inline] |
Used to unlock the held mutex earlier than destruction.
FXFORCEINLINE void FX::QMtxHold::relock | ( | ) | [inline] |
Used to relock a previously unlocked held mutex.
FXFORCEINLINE bool FX::QMtxHold::lockLost | ( | ) | const [inline] |
Returns true if when during a read-to-write lock transition the lock was lost.