Honeycomb
0.1
Component-Model Framework
|
A thread lock where the lock is acquired through a busy wait loop. More...
#include <Spin.h>
Public Types | |
typedef UniqueLock< SpinLock > | Scoped |
Public Member Functions | |
SpinLock () | |
SpinLock (const SpinLock &) | |
Can't copy, silently inits to default. More... | |
~SpinLock () | |
SpinLock & | operator= (const SpinLock &) |
Can't copy, silently does nothing. More... | |
void | lock () |
Acquire the lock. Thread waits in a busy loop until lock becomes available. More... | |
void | unlock () |
Release the lock. More... | |
bool | tryLock () |
Attempt to acquire the lock, returns immediately. Returns true if the lock was acquired, false otherwise. More... | |
bool | tryLock (MonoClock::Duration time) |
Attempt to acquire the lock for an amount of time. Returns true if the lock was acquired, false otherwise. More... | |
bool | tryLock (MonoClock::TimePoint time) |
Attempt to acquire the lock until a certain time. Returns true if the lock was acquired, false otherwise. More... | |
A thread lock where the lock is acquired through a busy wait loop.
Use when threads are expected to quickly acquire and release the lock.
The lock is recursive: one thread can acquire the lock multiple times, which must be followed by the same number of unlocks.
This class uses atomics, so locking without contention is faster than a platform Mutex.
typedef UniqueLock<SpinLock> honey::SpinLock::Scoped |
|
inline |
|
inline |
Can't copy, silently inits to default.
|
inline |
void honey::SpinLock::lock | ( | ) |
Acquire the lock. Thread waits in a busy loop until lock becomes available.
bool honey::SpinLock::tryLock | ( | ) |
Attempt to acquire the lock, returns immediately. Returns true if the lock was acquired, false otherwise.
|
inline |
Attempt to acquire the lock for an amount of time. Returns true if the lock was acquired, false otherwise.
bool honey::SpinLock::tryLock | ( | MonoClock::TimePoint | time | ) |
Attempt to acquire the lock until a certain time. Returns true if the lock was acquired, false otherwise.
void honey::SpinLock::unlock | ( | ) |
Release the lock.