Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/express/conditionVar.I

Go to the documentation of this file.
00001 // Filename: conditionVar.I
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 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: ConditionVar::Constructor
00022 //       Access: Public
00023 //  Description: You must pass in a Mutex to the condition variable
00024 //               constructor.  This mutex may be shared by other
00025 //               condition variables, if desired.  It is the caller's
00026 //               responsibility to ensure the Mutex object does not
00027 //               destruct during the lifetime of the condition
00028 //               variable.
00029 ////////////////////////////////////////////////////////////////////
00030 INLINE ConditionVar::
00031 ConditionVar(Mutex &mutex) :
00032   _mutex(mutex),
00033   _impl(mutex._impl)
00034 {
00035 }
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //     Function: ConditionVar::Destructor
00039 //       Access: Public
00040 //  Description:
00041 ////////////////////////////////////////////////////////////////////
00042 INLINE ConditionVar::
00043 ~ConditionVar() {
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: ConditionVar::Copy Constructor
00048 //       Access: Private
00049 //  Description: Do not attempt to copy condition variables.
00050 ////////////////////////////////////////////////////////////////////
00051 INLINE ConditionVar::
00052 ConditionVar(const ConditionVar &copy) : 
00053   _mutex(copy._mutex), 
00054   _impl(_mutex._impl)
00055 {
00056   nassertv(false);
00057 }
00058 
00059 ////////////////////////////////////////////////////////////////////
00060 //     Function: ConditionVar::Copy Assignment Operator
00061 //       Access: Private
00062 //  Description: Do not attempt to copy condition variables.
00063 ////////////////////////////////////////////////////////////////////
00064 INLINE void ConditionVar::
00065 operator = (const ConditionVar &copy) {
00066   nassertv(false);
00067 }
00068 
00069 ////////////////////////////////////////////////////////////////////
00070 //     Function: ConditionVar::get_mutex
00071 //       Access: Public
00072 //  Description: Returns the mutex associated with this condition
00073 //               variable.
00074 ////////////////////////////////////////////////////////////////////
00075 INLINE Mutex &ConditionVar::
00076 get_mutex() {
00077   return _mutex;
00078 }
00079 
00080 ////////////////////////////////////////////////////////////////////
00081 //     Function: ConditionVar::wait
00082 //       Access: Public
00083 //  Description: Waits on the condition.  The caller must already be
00084 //               holding the lock associated with the condition
00085 //               variable before calling this function.
00086 //
00087 //               wait() will release the lock, then go to sleep until
00088 //               some other thread calls signal() on this condition
00089 //               variable.  At that time at least one thread waiting
00090 //               on the same ConditionVar will grab the lock again,
00091 //               and then return from wait().
00092 //
00093 //               It is possible that wait() will return even if no one
00094 //               has called signal().  It is the responsibility of the
00095 //               calling process to verify the condition on return
00096 //               from wait, and possibly loop back to wait again if
00097 //               necessary.
00098 //
00099 //               Note the semantics of a condition variable: the mutex
00100 //               must be held before wait() is called, and it will
00101 //               still be held when wait() returns.  However, it will
00102 //               be temporarily released during the wait() call
00103 //               itself.
00104 ////////////////////////////////////////////////////////////////////
00105 INLINE void ConditionVar::
00106 wait() {
00107   _impl.wait();
00108 }
00109 
00110 ////////////////////////////////////////////////////////////////////
00111 //     Function: ConditionVar::signal
00112 //       Access: Public
00113 //  Description: Informs one of the other threads who are currently
00114 //               blocked on wait() that the relevant condition has
00115 //               changed.  If multiple threads are currently waiting,
00116 //               at least one of them will be woken up, although there
00117 //               is no way to predict which one.
00118 //
00119 //               The caller must be holding the mutex associated with
00120 //               the condition variable before making this call, which
00121 //               will not release the mutex.
00122 //
00123 //               If no threads are waiting, this is a no-op: the
00124 //               signal is lost.
00125 ////////////////////////////////////////////////////////////////////
00126 INLINE void ConditionVar::
00127 signal() {
00128   _impl.signal();
00129 }
00130 
00131 ////////////////////////////////////////////////////////////////////
00132 //     Function: ConditionVar::signal_all
00133 //       Access: Public
00134 //  Description: Wakes up all of the other threads currently blocked
00135 //               on wait().
00136 //
00137 //               The caller must be holding the mutex associated with
00138 //               the condition variable before making this call, which
00139 //               will not release the mutex.
00140 ////////////////////////////////////////////////////////////////////
00141 INLINE void ConditionVar::
00142 signal_all() {
00143   _impl.signal_all();
00144 }

Generated on Fri May 2 00:38:19 2003 for Panda by doxygen1.3