Panda3D
lightMutex.h
1 // Filename: lightMutex.h
2 // Created by: drose (08Oct08)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef LIGHTMUTEX_H
16 #define LIGHTMUTEX_H
17 
18 #include "pandabase.h"
19 #include "mutexDebug.h"
20 #include "lightMutexDirect.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : LightMutex
24 // Description : This is a standard, non-reentrant mutex, similar to
25 // the Mutex class. It is different from Mutex in the
26 // case of SIMPLE_THREADS: in this case, the LightMutex
27 // class compiles to nothing; it performs no locking
28 // whatsoever. It is therefore useful only to protect
29 // very small sections of code, during which you are
30 // confident there will be no thread yields.
31 //
32 // In the normal, system-threaded implementation, this
33 // class is exactly the same as Mutex.
34 //
35 // ConditionVars cannot be used with LightMutex; they
36 // work only with Mutex.
37 //
38 // This class inherits its implementation either from
39 // MutexDebug or LightMutexDirect, depending on the
40 // definition of DEBUG_THREADS.
41 ////////////////////////////////////////////////////////////////////
42 #ifdef DEBUG_THREADS
43 class EXPCL_PANDA_PIPELINE LightMutex : public MutexDebug
44 #else
45 class EXPCL_PANDA_PIPELINE LightMutex : public LightMutexDirect
46 #endif // DEBUG_THREADS
47 {
48 PUBLISHED:
49  INLINE LightMutex();
50 public:
51  INLINE LightMutex(const char *name);
52 PUBLISHED:
53  INLINE LightMutex(const string &name);
54  INLINE ~LightMutex();
55 private:
56  INLINE LightMutex(const LightMutex &copy);
57  INLINE void operator = (const LightMutex &copy);
58 };
59 
60 #include "lightMutex.I"
61 
62 #endif
This class implements a lightweight Mutex by making direct calls to the underlying implementation lay...
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition: lightMutex.h:45