Evo C++ Library v0.5.1
|
#include <evo/thread.h>
Condition object for thread synchronization.
-pthread
-lpthread
C/C++ -> Code Generation -> Runtime Library
Public Types | |
typedef pthread_cond_t | Handle |
typedef SmartLock< Condition > | Lock |
Lock object type – see SmartLock. More... | |
Public Member Functions | |
Condition () | |
Default constructor. More... | |
Condition (Mutex &mutex) | |
Constructor. More... | |
~Condition () | |
Destructor. More... | |
void | lock () |
Lock associated mutex. More... | |
void | lock_notify () |
Lock associated mutex, call notify(), then unlock. More... | |
void | lock_notify_all () |
Lock associated mutex, call notify_all(), then unlock. More... | |
bool | lock_wait (ulong timeout_ms=Condition::INF) |
Lock associated mutex, call wait(), then unlock. More... | |
void | notify () |
Notify and wake a waiting thread. More... | |
void | notify_all () |
Notify and wake all waiting threads. More... | |
bool | trylock () |
Try to lock associated mutex, fail if already locked (non-blocking). More... | |
bool | trylock (ulong timeout_ms) |
Try to lock associated mutex with a timeout. More... | |
void | unlock () |
Unlock associated mutex. More... | |
bool | wait (ulong timeout_ms=Condition::INF, bool locked=true) |
Wait for notification or timeout. More... | |
bool | wait_inf (bool locked=true) |
Wait for notification. More... | |
Public Attributes | |
Handle | handle |
Condition object handle – do not modify. More... | |
Mutex * | mutex |
Pointer to associated mutex, never NULL – do not modify. More... | |
bool | owned |
Whether associated mutex is owned by this – do not modify. More... | |
Static Public Attributes | |
static const ulong | INF = ULONG_MAX |
Infinite wait timeout value. More... | |
typedef pthread_cond_t Handle |
|
inline |
Default constructor.
Constructor.
mutex | Mutex to associate with |
|
inline |
Destructor.
|
inline |
|
inline |
Lock associated mutex, call notify(), then unlock.
|
inline |
Lock associated mutex, call notify_all(), then unlock.
|
inline |
Lock associated mutex, call wait(), then unlock.
timeout_ms | Wait timeout in milliseconds, 0 for immediate (no wait), INF for indefinitely |
|
inline |
Notify and wake a waiting thread.
|
inline |
Notify and wake all waiting threads.
|
inline |
Try to lock associated mutex, fail if already locked (non-blocking).
|
inline |
Try to lock associated mutex with a timeout.
timeout_ms | Timeout in milliseconds |
|
inline |
Unlock associated mutex.
|
inline |
Wait for notification or timeout.
locked=false
:timeout_ms
locked=true
timeout_ms | Wait timeout in milliseconds, 0 for immediate (no wait), INF for indefinitely |
locked | Whether to assume associated mutex is locked, false to lock it here |
|
inline |
|
static |
Infinite wait timeout value.
Mutex* mutex |
Pointer to associated mutex, never NULL – do not modify.
bool owned |
Whether associated mutex is owned by this – do not modify.