Panda3D
pmutex.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file pmutex.h
10  * @author cary
11  * @date 1998-09-16
12  */
13 
14 #ifndef PMUTEX_H
15 #define PMUTEX_H
16 
17 #include "pandabase.h"
18 #include "mutexDebug.h"
19 #include "mutexDirect.h"
20 
21 /**
22  * A standard mutex, or mutual exclusion lock. Only one thread can hold
23  * ("lock") a mutex at any given time; other threads trying to grab the mutex
24  * will block until the holding thread releases it.
25  *
26  * The standard mutex is not reentrant: a thread may not attempt to lock it
27  * twice. Although this may happen to work on some platforms (e.g. Win32),
28  * it will not work on all platforms; on some platforms, a thread can deadlock
29  * itself by attempting to lock the same mutex twice. If your code requires a
30  * reentrant mutex, use the ReMutex class instead.
31  *
32  * This class inherits its implementation either from MutexDebug or
33  * MutexDirect, depending on the definition of DEBUG_THREADS.
34  */
35 #ifdef DEBUG_THREADS
36 class EXPCL_PANDA_PIPELINE Mutex : public MutexDebug
37 #else
38 class EXPCL_PANDA_PIPELINE Mutex : public MutexDirect
39 #endif // DEBUG_THREADS
40 {
41 PUBLISHED:
42  INLINE Mutex();
43 public:
44  INLINE Mutex(const char *name);
45 PUBLISHED:
46  INLINE explicit Mutex(const std::string &name);
47  Mutex(const Mutex &copy) = delete;
48  ~Mutex() = default;
49 
50  void operator = (const Mutex &copy) = delete;
51 
52 public:
53  // This is a global mutex set aside for the purpose of protecting Notify
54  // messages from being interleaved between threads.
55  static Mutex _notify_mutex;
56 };
57 
58 #include "pmutex.I"
59 
60 #endif
This class implements a standard mutex by making direct calls to the underlying implementation layer.
Definition: mutexDirect.h:30
A standard mutex, or mutual exclusion lock.
Definition: pmutex.h:40
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.