Panda3D
 All Classes Functions Variables Enumerations
mutexSpinlockImpl.cxx
1 // Filename: mutexSpinlockImpl.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 "mutexSpinlockImpl.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: MutexSpinlockImpl::do_lock
23 // Access: Private
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 void MutexSpinlockImpl::
27 do_lock() {
28  while (AtomicAdjust::compare_and_exchange(_lock, 0, 1) != 0) {
29  }
30 }
31 
32 #endif // MUTEX_SPINLOCK
static Integer compare_and_exchange(Integer &mem, Integer old_value, Integer new_value)
Atomic compare and exchange.