Panda3D
conditionVarSpinlockImpl.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 conditionVarSpinlockImpl.h
10  * @author drose
11  * @date 2006-04-11
12  */
13 
14 #ifndef CONDITIONVARSPINLOCKIMPL_H
15 #define CONDITIONVARSPINLOCKIMPL_H
16 
17 #include "pandabase.h"
18 #include "selectThreadImpl.h"
19 
20 #ifdef MUTEX_SPINLOCK
21 
22 #include "mutexSpinlockImpl.h"
23 #include "pnotify.h"
24 #include "atomicAdjust.h"
25 
26 class MutexSpinlockImpl;
27 
28 /**
29  * Uses a simple user-space spinlock to implement a condition variable. It is
30  * usually not a good idea to use this implementation, unless you are building
31  * Panda for a specific application on a specific SMP machine, and you are
32  * confident that you have at least as many CPU's as you have threads.
33  */
34 class EXPCL_PANDA_PIPELINE ConditionVarSpinlockImpl {
35 public:
36  INLINE ConditionVarSpinlockImpl(MutexSpinlockImpl &mutex);
37  INLINE ~ConditionVarSpinlockImpl();
38 
39  void wait();
40  void wait(double timeout);
41  INLINE void notify();
42  INLINE void notify_all();
43 
44 private:
45  MutexSpinlockImpl &_mutex;
46  TVOLATILE AtomicAdjust::Integer _event;
47 };
48 
50 
51 #endif // MUTEX_SPINLOCK
52 
53 #endif
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.