Panda3D
 All Classes Functions Variables Enumerations
pmutex.h
1 // Filename: pmutex.h
2 // Created by: cary (16Sep98)
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 PMUTEX_H
16 #define PMUTEX_H
17 
18 #include "pandabase.h"
19 #include "mutexDebug.h"
20 #include "mutexDirect.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : Mutex
24 // Description : A standard mutex, or mutual exclusion lock. Only one
25 // thread can hold ("lock") a mutex at any given time;
26 // other threads trying to grab the mutex will block
27 // until the holding thread releases it.
28 //
29 // The standard mutex is not reentrant: a thread may not
30 // attempt to lock it twice. Although this may happen
31 // to work on some platforms (e.g. Win32), it will not
32 // work on all platforms; on some platforms, a thread
33 // can deadlock itself by attempting to lock the same
34 // mutex twice. If your code requires a reentrant
35 // mutex, use the ReMutex class instead.
36 //
37 // This class inherits its implementation either from
38 // MutexDebug or MutexDirect, depending on the
39 // definition of DEBUG_THREADS.
40 ////////////////////////////////////////////////////////////////////
41 #ifdef DEBUG_THREADS
42 class EXPCL_PANDA_PIPELINE Mutex : public MutexDebug
43 #else
44 class EXPCL_PANDA_PIPELINE Mutex : public MutexDirect
45 #endif // DEBUG_THREADS
46 {
47 PUBLISHED:
48  INLINE Mutex();
49 public:
50  INLINE Mutex(const char *name);
51 PUBLISHED:
52  INLINE Mutex(const string &name);
53  INLINE ~Mutex();
54 private:
55  INLINE Mutex(const Mutex &copy);
56  INLINE void operator = (const Mutex &copy);
57 
58 public:
59  // This is a global mutex set aside for the purpose of protecting
60  // Notify messages from being interleaved between threads.
61  static Mutex _notify_mutex;
62 };
63 
64 #include "pmutex.I"
65 
66 #endif
A standard mutex, or mutual exclusion lock.
Definition: pmutex.h:44
This class implements a standard mutex by making direct calls to the underlying implementation layer...
Definition: mutexDirect.h:32