Panda3D
|
00001 // Filename: conditionVarDirect.h 00002 // Created by: drose (13Feb06) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef CONDITIONVARDIRECT_H 00016 #define CONDITIONVARDIRECT_H 00017 00018 #include "pandabase.h" 00019 #include "mutexDirect.h" 00020 #include "conditionVarImpl.h" 00021 00022 #ifndef DEBUG_THREADS 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Class : ConditionVarDirect 00026 // Description : A condition variable, usually used to communicate 00027 // information about changing state to a thread that is 00028 // waiting for something to happen. A condition 00029 // variable can be used to "wake up" a thread when some 00030 // arbitrary condition has changed. 00031 // 00032 // A condition variable is associated with a single 00033 // mutex, and several condition variables may share the 00034 // same mutex. 00035 //////////////////////////////////////////////////////////////////// 00036 class EXPCL_PANDA_PIPELINE ConditionVarDirect { 00037 public: 00038 INLINE ConditionVarDirect(MutexDirect &mutex); 00039 INLINE ~ConditionVarDirect(); 00040 private: 00041 INLINE ConditionVarDirect(const ConditionVarDirect ©); 00042 INLINE void operator = (const ConditionVarDirect ©); 00043 00044 PUBLISHED: 00045 INLINE MutexDirect &get_mutex() const; 00046 00047 BLOCKING INLINE void wait(); 00048 BLOCKING INLINE void wait(double timeout); 00049 INLINE void notify(); 00050 void output(ostream &out) const; 00051 00052 private: 00053 MutexDirect &_mutex; 00054 ConditionVarImpl _impl; 00055 }; 00056 00057 INLINE ostream & 00058 operator << (ostream &out, const ConditionVarDirect &cv) { 00059 cv.output(out); 00060 return out; 00061 } 00062 00063 #include "conditionVarDirect.I" 00064 00065 #endif // !DEBUG_THREADS 00066 00067 #endif