#include <SpinLock.h>
Public Member Functions | |
bool | lock () |
SpinLock () | |
bool | tryLock () |
void | unlock () |
Unlocks the mutex. | |
Private Types | |
enum | LockState { LOCKED, UNLOCKED } |
States of the lock. More... | |
Private Attributes | |
boost::atomic< LockState > | m_state |
Current lock state. |
A spin lock for very short critical sections. Busy-waits until the lock is acquired. Modeled after the example given in the boost::atomic documentation.
Definition at line 35 of file SpinLock.h.
enum icl_core::thread::SpinLock::LockState [private] |
icl_core::thread::SpinLock::SpinLock | ( | ) | [inline] |
Definition at line 38 of file SpinLock.h.
bool icl_core::thread::SpinLock::lock | ( | ) | [inline] |
Locks the mutex. Busy-waits until the mutex can be locked.
true
. When the function returns the mutex is guaranteed to be locked. Definition at line 46 of file SpinLock.h.
bool icl_core::thread::SpinLock::tryLock | ( | ) | [inline] |
Tries to lock the mutex without blocking. The mutex is locked if it is available.
true
if the mutex has been locked, false
otherwise. Definition at line 60 of file SpinLock.h.
void icl_core::thread::SpinLock::unlock | ( | ) | [inline] |
Unlocks the mutex.
Definition at line 66 of file SpinLock.h.
boost::atomic<LockState> icl_core::thread::SpinLock::m_state [private] |
Current lock state.
Definition at line 80 of file SpinLock.h.