Interface class for mutex objects. More...
Public Member Functions | |
virtual | ~MutexInterface () |
Virtual destructor. | |
virtual bool | acquire (MilliSecond timeout=Infinite)=0 |
Acquire the mutex with a timeout. More... | |
virtual bool | release ()=0 |
Release the mutex. More... | |
Interface class for mutex objects.
A mutex is a general mutual exclusion mechanism. This interface class defines the generic interface of a mutex. Various concrete mutex classes can be defined based on distinct lower-level synchronization mechanisms.
For each successful call to acquire(), there must be one call to release().
This interface class does not define whether the actual mutex should be recursive or not. A mutex is defined as recursive if nested pairs of acquire() / release() are allowed on the mutex. If the implementation is a recursive mutex, there must be exactly one release() for each nested invocation of acquire().
The concrete class ts::NullMutex is an empty mutex implementation which does nothing and can be used wherever a MutexInterface is required but no actual synchronization is necessary (non-threaded applications for instances).
|
pure virtual |
Acquire the mutex with a timeout.
The actual semantic of this operation depends on the mutex concrete class. Typically, the concrete class attempts to acquire a low-level synchronization mechanism and blocks until the mutex is granted or a timeout occurs.
[in] | timeout | Maximum number of milliseconds to wait for the mutex. |
Implemented in ts::Mutex, and ts::NullMutex.
|
pure virtual |
Release the mutex.
Implemented in ts::Mutex, and ts::NullMutex.