3es
0.7
|
A spin lock implementation. More...
#include <3esspinlock.h>
Public Member Functions | |
SpinLock () | |
Construct a spin lock (unlocked). | |
~SpinLock () | |
Destructor. | |
void | lock () |
Block until the spin lock can be attained. | |
bool | try_lock () |
Try attain the lock without blocking. More... | |
void | unlock () |
Unlock the lock. More... | |
A spin lock implementation.
Prefered over std::mutex as that class can be very slow (i.e, Clang OSX).
This is a naive implementation and does not support re-locking.
Best used with std::unique_lock
as an exception and scope safe guard.
bool tes::SpinLock::try_lock | ( | ) |
Try attain the lock without blocking.
void tes::SpinLock::unlock | ( | ) |
Unlock the lock.
Should only ever be called by the scope which called lock()
or succeeded at try_lock
.