ML Reference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00005 00010 //---------------------------------------------------------------------------------- 00011 #ifndef __mlWaitCondition_H 00012 #define __mlWaitCondition_H 00013 00014 #ifndef __mlUtilsSystem_H 00015 #include "mlUtilsSystem.h" 00016 #endif 00017 00018 #include "mlMutex.h" 00019 00020 ML_UTILS_START_NAMESPACE 00021 00022 //-------------------------------------------------------------------- 00025 00041 //-------------------------------------------------------------------- 00042 class WaitCondition 00043 { 00044 public: 00045 WaitCondition() {}; 00046 00047 //-------------------------------------------------------------------- 00050 //-------------------------------------------------------------------- 00051 void wait(Lock& lock) 00052 { 00053 _condition.wait(lock); 00054 } 00055 00056 //-------------------------------------------------------------------- 00059 //-------------------------------------------------------------------- 00060 template<typename duration_type> bool wait(Lock& lock, duration_type duration) 00061 { 00062 return _condition.timed_wait(lock, duration); 00063 } 00064 00065 //-------------------------------------------------------------------- 00067 //-------------------------------------------------------------------- 00068 void notifyAll() 00069 { 00070 _condition.notify_all(); 00071 } 00072 00073 //-------------------------------------------------------------------- 00075 //-------------------------------------------------------------------- 00076 void notifyOne() 00077 { 00078 _condition.notify_one(); 00079 } 00080 00081 private: 00083 boost::condition _condition; 00084 }; 00085 00086 ML_UTILS_END_NAMESPACE 00087 00088 #endif // __mlWaitCondition_H 00089 00090