CopperSpice API  1.7.2
QBasicMutex Class Reference

The QBasicMutex class provides access serialization between threads. More...

Inheritance diagram for QBasicMutex:
QMutex

Public Methods

bool isRecursive ()
 
void lock ()
 
bool tryLock (int timeout=0)
 
void unlock ()
 

Friends

class QMutex
 

Detailed Description

Base class for QMutex. The QBasicMutex class is used internally by CopperSpice and are not part of the public API.

Use QMutex in your applications.

Method Documentation

bool QBasicMutex::isRecursive ( )

Returns true if the mutex is recursive.

void QBasicMutex::lock ( )
inline

Locks the mutex. If another thread has locked the mutex then this call will block until that thread has unlocked it.

Calling this function multiple times on the same mutex from the same thread is allowed if this mutex is a recursive mutex. If this mutex is a non-recursive mutex, this function will dead-lock when the mutex is locked recursively.

See also
unlock()
bool QBasicMutex::tryLock ( int  timeout = 0)
inline

Attempts to lock the mutex. This function returns true if the lock was obtained, otherwise it returns false. If another thread has locked the mutex, this function will wait for at most timeout milliseconds for the mutex to become available.

Note: Passing a negative number as the timeout is equivalent to calling lock(), i.e. this function will wait forever until mutex can be locked if timeout is negative.

If the lock was obtained, the mutex must be unlocked with unlock() before another thread can successfully lock it.

Calling this function multiple times on the same mutex from the same thread is allowed if this mutex is a recursive mutex. If this mutex is a non-recursive mutex, this function will always return false when attempting to lock the mutex recursively.

See also
lock(), unlock()
void QBasicMutex::unlock ( )
inline

Unlocks the mutex. Attempting to unlock a mutex in a different thread to the one that locked it results in an error. Unlocking a mutex that is not locked results in undefined behavior.

See also
lock()