Panda3D
conditionVarSpinlockImpl.cxx
1 // Filename: conditionVarSpinlockImpl.cxx
2 // Created by: drose (11Apr06)
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 #include "selectThreadImpl.h"
16 
17 #ifdef MUTEX_SPINLOCK
18 
19 #include "conditionVarSpinlockImpl.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: ConditionVarSpinlockImpl::wait
23 // Access: Public
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 void ConditionVarSpinlockImpl::
27 wait() {
28  AtomicAdjust::Integer current = _event;
29  _mutex.release();
30 
31  while (AtomicAdjust::get(_event) == current) {
32  }
33 
34  _mutex.acquire();
35 }
36 
37 #endif // MUTEX_SPINLOCK
static Integer get(const Integer &var)
Atomically retrieves the snapshot value of the indicated variable.