Itasca C++ Interface
Loading...
Searching...
No Matches
Public Member Functions | List of all members
IMutexLocker Class Reference

An automatic QMutex lock/unlock helper class. More...

#include <basemutex.h>

Public Member Functions

 IMutexLocker (QMutex *mutex)
 Lock the mutex on construction, default simple version.
 
 IMutexLocker (QMutex *mutex, int time, int line, const char *file)
 
 ~IMutexLocker ()
 Destructor, if locked unlocks the mutex.
 
QMutex * mutex ()
 Returns a pointer to the mutex claimed by this locker.
 
void unlock ()
 Explicitly unlocks the mutex before destruction.
 
void relock (int time=30000, int line=0, const char *file=0)
 Explicitly relocks the mutex after destruction, if unlock() was called.
 

Detailed Description

An automatic QMutex lock/unlock helper class.

Similar to QMutexLocker, but adds some debugging aids.
Specifically, file,line tracking of who is asking for the mutex.
Also, allows a "timeout" error to be thrown to help detect race conditions. This class is not intended to be created directly, instead use the macros LOCK_MUTEX1, LOCK_MUTEX2, and LOCK_MUTEX3. The QMutexLocker class itself is disabled via use of the preprocessor, to force coders to use this version.

Constructor & Destructor Documentation

◆ IMutexLocker()

IMutexLocker::IMutexLocker ( QMutex * mutex,
int time,
int line,
const char * file )
inline

Lock the mutex on constructor, but allows specification of timeout time, file name and line number.

Parameters
mutexA pointer to the mutex being claimed.
timeThe timeout time in milliseconds.
lineThe line number of the source where IMutexLocker was created.
fileThe file name of the source where IMutexLocker was created.

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