FX::QMtxHold Class Reference

#include <QThread.h>

List of all members.


Detailed Description

Helper class for using mutexes.

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


Member Enumeration Documentation

Enumerates kinds of lock hold.

Enumerator:
LockAndUnlock  Locks on construction and unlocks on destruction (the default).
UnlockAndRelock  The opposite (very rarely used).
AcceptNullMutex  Accepts a null mutex pointer.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.


The documentation for this class was generated from the following file:

(C) 2002-2008 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Jun 13 22:28:54 2008 for TnFOX by doxygen v1.5.6