36 #ifndef __PARA_PTH_COND_VAR_H__ 37 #define __PARA_PTH_COND_VAR_H__ 86 int const error = pthread_cond_init(&cond, 0);
102 pthread_cond_destroy(&cond);
114 if( ownMutex )
delete lck;
136 lck->
lock(file, line);
152 int const error = pthread_cond_wait(&cond, &lck->
mtx);
166 int const error = pthread_cond_signal(&cond);
179 int const error = pthread_cond_broadcast(&cond);
200 #define CONDITIONVARIABLE_WAIT(var,cond) do { \ 201 LockRAII raiiwait_((var)->getLock(), __FILE__, __LINE__); \ 207 #endif // __PARA_PTH_COND_VAR_H__
pthread_cond_t cond
The low-level condition variable.
void setLock(Lock *l)
set Lock from outside.
void lock()
Acquire this lock. The function sets the internal file/line (debugging) fields to generic values...
~ConditionVariable()
Destroy this condition variable. If the constructor allocated a new Lock for this condition variable ...
ConditionVariable(Lock *l=0)
Create a new condition variable. If l is NULL then the constructor will create a new Lock instance an...
bool ownMutex
This is true iff the constructor did allocate lck.
void broadcast()
Signal on this condition variable. Broadcasting on a condition variable will wake up ALL threads that...
Lock * lck
The lock associated with this instance.
Pthread lock for UG Framework.
void wait()
Wait for this condition variable. The calling thread MUST hold the lock associated with this conditio...
void unlock()
Release the lock associated with this condition variable.
void unlock()
Release this lock.
pthread_mutex_t mtx
The low-level mutex that implements this lock.
Class that implements a lock. The class wraps around pthread_mutex_t and adds some safeguards...
void lock(char const *file, int line)
Acquire the lock associated with this condition variable.
Exception that is thrown whenever something goes wrong with a lock.
void lock()
Acquire the lock associated with this condition variable.
ConditionVariable(ConditionVariable const &)
No copying or assignment of condition variables.
Lock * getLock() const
Get the lock associated with this condition variable.
void signal()
Signal this condition variable. Signalling a condition variable will wake up ONE thread that is curre...
ConditionVariable & operator=(ConditionVariable const &)