00001 #ifndef _sys_windows_Condition_h
00002 #define _sys_windows_Condition_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "qpid/sys/Mutex.h"
00026 #include "qpid/sys/Time.h"
00027
00028 #include <time.h>
00029 #include <boost/noncopyable.hpp>
00030 #include <boost/thread/condition.hpp>
00031 #include <boost/thread/thread_time.hpp>
00032 #include <windows.h>
00033
00034 namespace qpid {
00035 namespace sys {
00036
00037
00038 void toPtime(boost::posix_time::ptime& pt, const AbsTime& t);
00039
00043 class Condition : private boost::noncopyable
00044 {
00045 public:
00046 inline Condition();
00047 inline ~Condition();
00048 inline void wait(Mutex&);
00049 inline bool wait(Mutex&, const AbsTime& absoluteTime);
00050 inline void notify();
00051 inline void notifyAll();
00052
00053 private:
00054 boost::condition_variable_any condition;
00055 };
00056
00057 Condition::Condition() {
00058 }
00059
00060 Condition::~Condition() {
00061 }
00062
00063 void Condition::wait(Mutex& mutex) {
00064 condition.wait(mutex.mutex);
00065 }
00066
00067 bool Condition::wait(Mutex& mutex, const AbsTime& absoluteTime){
00068 boost::system_time st;
00069 toPtime(st, absoluteTime);
00070 return condition.timed_wait(mutex.mutex, st);
00071 }
00072
00073 void Condition::notify(){
00074 condition.notify_one();
00075 }
00076
00077 void Condition::notifyAll(){
00078 condition.notify_all();
00079 }
00080
00081 }}
00082 #endif