00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef WT_COND_H
00022
#define WT_COND_H
00023
00024
#include <wefts_mutex.h>
00025
#include <wefts_cleancond.h>
00026
00027
namespace Wefts {
00028
00045 class Condition
00046 {
00047
protected:
00049 OSCondition m_cond;
00054 Mutex *
m_my_mutex;
00055
00056
00057
public:
00060 Condition(
Mutex *mtx=0 )
00061 {
00062
m_my_mutex = mtx;
00063 }
00064
00065 ~Condition() {}
00066
00076 virtual inline bool wait(
CleanupHandler *cup = 0,
int pos = 0 ) {
00077
CleanupItem clup( cup, pos,
this );
00078
return m_cond.
wait(
m_my_mutex->
m_mutex, clup );
00079 }
00080
00088 void setMutex(
Mutex *mtx) {
m_my_mutex = mtx; }
00089
00090 Mutex *
getMutex() {
return m_my_mutex; }
00091
00113 virtual inline bool wait(
long seconds,
long nanoseconds,
CleanupHandler *cup = 0,
int pos = 0)
00114 {
00115
CleanupItem clup( cup, pos,
this );
00116
return m_cond.
timedWait(
m_my_mutex->
m_mutex, seconds, nanoseconds, clup );
00117 }
00118
00119
00134 inline bool wait(
double seconds,
CleanupHandler *cup = 0,
int pos = 0 )
00135 {
00136
return wait(
long( seconds ),
00137
long( (seconds -
long(seconds)) *1000000000l), cup, pos );
00138 }
00139
00143 virtual inline void signal() {
m_cond.
signal(); }
00144
00155 virtual inline void signalOne() {
m_cond.
signalOne(); }
00156
00157 };
00158
00159 }
00160
00161
#endif
00162