|
libpsynth 0.2.1
|
A mutex is a MUTual EXclusion device, and is useful for protecting shared data structures from concurrent modifications, and implementing critical sections and monitors. More...
#include <mutex.hpp>
Public Types | |
| enum | type { DEFAULT = PTHREAD_MUTEX_DEFAULT, FAST = PTHREAD_MUTEX_NORMAL, RECURSIVE = PTHREAD_MUTEX_RECURSIVE, ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK } |
| Mutex type. More... | |
Public Member Functions | |
| mutex (int type=DEFAULT) | |
| Constuctor. | |
| ~mutex () | |
| Destructor. | |
| void | reset (int type=DEFAULT) |
| Rebuilds the mutex. | |
| bool | lock () const |
| Locks the mutex. | |
| bool | try_lock () const |
| Tries to lock the mutex. | |
| void | unlock () const |
| Unlocks the mutex. | |
Friends | |
| class | condition |
A mutex is a MUTual EXclusion device, and is useful for protecting shared data structures from concurrent modifications, and implementing critical sections and monitors.
A mutex has two possible states: unlocked (not owned by any thread), and locked (owned by one thread). A mutex can never be owned by two different threads simultaneously. A thread attempting to lock a mutex that is already locked by another thread is suspended until the owning thread unlocks the mutex first.
| enum psynth::mutex::type |
| psynth::mutex::mutex | ( | int | type = DEFAULT | ) | [inline] |
Constuctor.
| Mutex | type. Defaults to DEFAULT. |
| psynth::mutex::~mutex | ( | ) | [inline] |
Destructor.
| bool psynth::mutex::lock | ( | ) | const [inline] |
Locks the mutex.
If a second thread calls lock it will block until the owner of the mutex -the first thread that called lock- calls unlock.
| void psynth::mutex::reset | ( | int | type = DEFAULT | ) | [inline] |
Rebuilds the mutex.
| type | New mutex type. |
| bool psynth::mutex::try_lock | ( | ) | const [inline] |
Tries to lock the mutex.
true if we now own the mutex or false if the mutex is already locked. | void psynth::mutex::unlock | ( | ) | const [inline] |
Unlocks the mutex.
friend class condition [friend] |
1.7.4