Panda3D
|
00001 // Filename: lightMutexDirect.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 LIGHTMUTEXDIRECT_H 00016 #define LIGHTMUTEXDIRECT_H 00017 00018 #include "pandabase.h" 00019 #include "mutexImpl.h" 00020 00021 class Thread; 00022 00023 #ifndef DEBUG_THREADS 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : LightMutexDirect 00027 // Description : This class implements a lightweight Mutex by making 00028 // direct calls to the underlying implementation layer. 00029 // It doesn't perform any debugging operations. 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDA_PIPELINE LightMutexDirect { 00032 protected: 00033 INLINE LightMutexDirect(); 00034 INLINE ~LightMutexDirect(); 00035 private: 00036 INLINE LightMutexDirect(const LightMutexDirect ©); 00037 INLINE void operator = (const LightMutexDirect ©); 00038 00039 PUBLISHED: 00040 BLOCKING INLINE void acquire() const; 00041 INLINE void release() const; 00042 INLINE bool debug_is_locked() const; 00043 00044 INLINE void set_name(const string &name); 00045 INLINE void clear_name(); 00046 INLINE bool has_name() const; 00047 INLINE string get_name() const; 00048 00049 void output(ostream &out) const; 00050 00051 private: 00052 #ifdef DO_PSTATS 00053 // When PStats is compiled in, we use the full implementation of 00054 // LightMutex, even in the SIMPLE_THREADS case. We have to do this 00055 // since any PStatTimer call may trigger a context switch, and any 00056 // low-level context switch requires all containing mutexes to be 00057 // true mutexes. 00058 MutexTrueImpl _impl; 00059 #else 00060 MutexImpl _impl; 00061 #endif // DO_PSTATS 00062 }; 00063 00064 INLINE ostream & 00065 operator << (ostream &out, const LightMutexDirect &m) { 00066 m.output(out); 00067 return out; 00068 } 00069 00070 #include "lightMutexDirect.I" 00071 00072 #endif // !DEBUG_THREADS 00073 00074 #endif