00001 // Filename: conditionVar.h 00002 // Created by: drose (09Aug02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef CONDITIONVAR_H 00020 #define CONDITIONVAR_H 00021 00022 #include "pandabase.h" 00023 #include "pmutex.h" 00024 #include "conditionVarImpl.h" 00025 #include "notify.h" 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : ConditionVar 00029 // Description : A condition variable, usually used to communicate 00030 // information about changing state to a thread that is 00031 // waiting for something to happen. A condition 00032 // variable can be used to "wake up" a thread when some 00033 // arbitrary condition has changed. 00034 // 00035 // A condition variable is associated with a single 00036 // mutex, and several condition variables may share the 00037 // same mutex. 00038 //////////////////////////////////////////////////////////////////// 00039 class EXPCL_PANDAEXPRESS ConditionVar { 00040 public: 00041 INLINE ConditionVar(Mutex &mutex); 00042 INLINE ~ConditionVar(); 00043 private: 00044 INLINE ConditionVar(const ConditionVar ©); 00045 INLINE void operator = (const ConditionVar ©); 00046 00047 public: 00048 INLINE Mutex &get_mutex(); 00049 00050 INLINE void wait(); 00051 INLINE void signal(); 00052 INLINE void signal_all(); 00053 00054 private: 00055 Mutex &_mutex; 00056 ConditionVarImpl _impl; 00057 }; 00058 00059 #include "conditionVar.I" 00060 00061 #endif