Honeycomb  0.1
Component-Model Framework
Public Types | Public Member Functions | List of all members
honey::SpinLock Class Reference

A thread lock where the lock is acquired through a busy wait loop. More...

#include <Spin.h>

Public Types

typedef UniqueLock< SpinLockScoped
 

Public Member Functions

 SpinLock ()
 
 SpinLock (const SpinLock &)
 Can't copy, silently inits to default. More...
 
 ~SpinLock ()
 
SpinLockoperator= (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...
 

Detailed Description

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.

Member Typedef Documentation

Constructor & Destructor Documentation

honey::SpinLock::SpinLock ( )
inline
honey::SpinLock::SpinLock ( const SpinLock )
inline

Can't copy, silently inits to default.

honey::SpinLock::~SpinLock ( )
inline

Member Function Documentation

void honey::SpinLock::lock ( )

Acquire the lock. Thread waits in a busy loop until lock becomes available.

SpinLock& honey::SpinLock::operator= ( const SpinLock )
inline

Can't copy, silently does nothing.

bool honey::SpinLock::tryLock ( )

Attempt to acquire the lock, returns immediately. Returns true if the lock was acquired, false otherwise.

bool honey::SpinLock::tryLock ( MonoClock::Duration  time)
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.


The documentation for this class was generated from the following files: