struct SpinLock : public Moveable<SpinLock>
Lightweight busywaiting synchronization lock. Unlike Mutex, SpinLock waits in a loop until resource becomes available, thus avoiding costs of contention system context switch at the price of active waiting. SpinLock methods are also usually inlined (and trivial). SpinLock is not reentrant and also not fair (if more threads are waiting on the same SpinLock, the order of acquiring it is not specified).
bool TryEnter()
Tries to acquire lock, returns true of lock acquired.
void Enter()
Acquires lock.
void Wait()
Waits until there is a chance that the lock can be acquired.
void Leave()
Releases lock.
class Lock : private NoCopy
This nested class automates calls to Mutex::Enter / Mutex::Leave for block of code using C++ constructor / destructor rules. Using operator StaticMutex::Mutex, it can be used with StaticMutex as well.
Constructor / Destructor detail
|
|
Lock(SpinLock& s)
Performs s.Enter().
~Lock()
Performs s.Leave() where s is the constructor parameter.
|