Panda3D

Loading...
Searching...
No Matches
mutexHolder.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 mutexHolder.h
10 * @author drose
11 * @date 2002-08-09
12 */
13
14#ifndef MUTEXHOLDER_H
15#define MUTEXHOLDER_H
16
17#include "pandabase.h"
18#include "pmutex.h"
19
20/**
21 * A lightweight C++ object whose constructor calls acquire() and whose
22 * destructor calls release() on a mutex. It is a C++ convenience wrapper to
23 * call release() automatically when a block exits (for instance, on return).
24 */
25 class EXPCL_PANDA_PIPELINE MutexHolder {
26 public:
27 INLINE MutexHolder(const Mutex &mutex);
28 INLINE MutexHolder(const Mutex &mutex, Thread *current_thread);
29 INLINE MutexHolder(Mutex *&mutex);
30 MutexHolder(const MutexHolder &copy) = delete;
31 INLINE ~MutexHolder();
32
33 MutexHolder &operator = (const MutexHolder &copy) = delete;
34
35 private:
36 // If HAVE_THREADS is defined, the Mutex class implements an actual mutex
37 // object of some kind. If HAVE_THREADS is not defined, this will be a
38 // MutexDummyImpl, which does nothing much anyway, so we might as well not
39 // even store a pointer to one.
40#if defined(HAVE_THREADS) || defined(DEBUG_THREADS)
41 const Mutex *_mutex;
42#endif
43};
44
45#include "mutexHolder.I"
46
47#endif
Mutex
A standard mutex, or mutual exclusion lock.
Definition pmutex.h:40
Thread
A thread; that is, a lightweight process.
Definition thread.h:46
mutexHolder.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmutex.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.