Panda3D
|
00001 // Filename: conditionVar.h 00002 // Created by: drose (09Aug02) 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 CONDITIONVAR_H 00016 #define CONDITIONVAR_H 00017 00018 #include "pandabase.h" 00019 #include "conditionVarDebug.h" 00020 #include "conditionVarDirect.h" 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : ConditionVar 00024 // Description : A condition variable, usually used to communicate 00025 // information about changing state to a thread that is 00026 // waiting for something to happen. A condition 00027 // variable can be used to "wake up" a thread when some 00028 // arbitrary condition has changed. 00029 // 00030 // The ConditionVar class does not support the full 00031 // semantics of POSIX condition variables. In 00032 // particular, it does not support the broadcast or 00033 // notify_all function. See ConditionVarFull for a more 00034 // complete (but possibly more expensive) API. 00035 // 00036 // A condition variable is associated with a single 00037 // mutex, and several condition variables may share the 00038 // same mutex. 00039 // 00040 // This class inherits its implementation either from 00041 // ConditionVarDebug or ConditionVarDirect, depending on 00042 // the definition of DEBUG_THREADS. 00043 //////////////////////////////////////////////////////////////////// 00044 #ifdef DEBUG_THREADS 00045 class EXPCL_PANDA_PIPELINE ConditionVar : public ConditionVarDebug 00046 #else 00047 class EXPCL_PANDA_PIPELINE ConditionVar : public ConditionVarDirect 00048 #endif // DEBUG_THREADS 00049 { 00050 PUBLISHED: 00051 INLINE ConditionVar(Mutex &mutex); 00052 INLINE ~ConditionVar(); 00053 private: 00054 INLINE ConditionVar(const ConditionVar ©); 00055 INLINE void operator = (const ConditionVar ©); 00056 00057 // These methods are inherited from the base class. 00058 // INLINE void wait(); 00059 // INLINE void notify(); 00060 00061 private: 00062 // The notify_all() method is specifically *not* provided by 00063 // ConditionVar. Use ConditionVarFull if you need to call this 00064 // method. 00065 INLINE void notify_all(); 00066 00067 PUBLISHED: 00068 INLINE Mutex &get_mutex() const; 00069 }; 00070 00071 #include "conditionVar.I" 00072 00073 #endif