00001 // Filename: lightMutex.h 00002 // Created by: drose (08Oct08) 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 LIGHTMUTEX_H 00016 #define LIGHTMUTEX_H 00017 00018 #include "pandabase.h" 00019 #include "mutexDebug.h" 00020 #include "lightMutexDirect.h" 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : LightMutex 00024 // Description : This is a standard, non-reentrant mutex, similar to 00025 // the Mutex class. It is different from Mutex in the 00026 // case of SIMPLE_THREADS: in this case, the LightMutex 00027 // class compiles to nothing; it performs no locking 00028 // whatsoever. It is therefore useful only to protect 00029 // very small sections of code, during which you are 00030 // confident there will be no thread yields. 00031 // 00032 // In the normal, system-threaded implementation, this 00033 // class is exactly the same as Mutex. 00034 // 00035 // ConditionVars cannot be used with LightMutex; they 00036 // work only with Mutex. 00037 // 00038 // This class inherits its implementation either from 00039 // MutexDebug or LightMutexDirect, depending on the 00040 // definition of DEBUG_THREADS. 00041 //////////////////////////////////////////////////////////////////// 00042 #ifdef DEBUG_THREADS 00043 class EXPCL_PANDA_PIPELINE LightMutex : public MutexDebug 00044 #else 00045 class EXPCL_PANDA_PIPELINE LightMutex : public LightMutexDirect 00046 #endif // DEBUG_THREADS 00047 { 00048 PUBLISHED: 00049 INLINE LightMutex(); 00050 public: 00051 INLINE LightMutex(const char *name); 00052 PUBLISHED: 00053 INLINE LightMutex(const string &name); 00054 INLINE ~LightMutex(); 00055 private: 00056 INLINE LightMutex(const LightMutex ©); 00057 INLINE void operator = (const LightMutex ©); 00058 }; 00059 00060 #include "lightMutex.I" 00061 00062 #endif