00001 // Filename: pmutex.I 00002 // Created by: drose (08Aug02) 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: Mutex::Constructor 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE Mutex:: 00026 Mutex() { 00027 } 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: Mutex::Destructor 00031 // Access: Public 00032 // Description: 00033 //////////////////////////////////////////////////////////////////// 00034 INLINE Mutex:: 00035 ~Mutex() { 00036 } 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Function: Mutex::Copy Constructor 00040 // Access: Private 00041 // Description: Do not attempt to copy mutexes. 00042 //////////////////////////////////////////////////////////////////// 00043 INLINE Mutex:: 00044 Mutex(const Mutex ©) { 00045 nassertv(false); 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: Mutex::Copy Assignment Operator 00050 // Access: Private 00051 // Description: Do not attempt to copy mutexes. 00052 //////////////////////////////////////////////////////////////////// 00053 INLINE void Mutex:: 00054 operator = (const Mutex ©) { 00055 nassertv(false); 00056 } 00057 00058 //////////////////////////////////////////////////////////////////// 00059 // Function: Mutex::lock 00060 // Access: Public 00061 // Description: Grabs the mutex if it is available. If it is not 00062 // available, blocks until it becomes available, then 00063 // grabs it. In either case, the function does not 00064 // return until the mutex is held; you should then call 00065 // unlock(). 00066 // 00067 // This method is considered const so that you can lock 00068 // and unlock const mutexes, mainly to allow thread-safe 00069 // access to otherwise const data. 00070 // 00071 // Also see MutexHolder. 00072 //////////////////////////////////////////////////////////////////// 00073 INLINE void Mutex:: 00074 lock() const { 00075 ((MutexImpl &)_impl).lock(); 00076 } 00077 00078 //////////////////////////////////////////////////////////////////// 00079 // Function: Mutex::release 00080 // Access: Public 00081 // Description: Releases the mutex. It is an error to call this if 00082 // the mutex was not already locked. 00083 // 00084 // This method is considered const so that you can lock 00085 // and unlock const mutexes, mainly to allow thread-safe 00086 // access to otherwise const data. 00087 //////////////////////////////////////////////////////////////////// 00088 INLINE void Mutex:: 00089 release() const { 00090 ((MutexImpl &)_impl).release(); 00091 }