Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site











SourceForge.net Logo

SpinLock

 

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).

 

Public Method List

 

bool TryEnter()

Tries to acquire lock, returns true of lock acquired.

 


 

void Enter()

Acquires lock.

 


 

void Leave()

Releases lock.

 

 

 

SpinLock::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.

 

Last edit by cxl on 01/07/2016. Do you want to contribute?. T++