Lunchbox  1.4.0
Public Member Functions
lunchbox::SpinLock Class Reference

A fast lock for uncontended memory access. More...

#include <spinLock.h>

+ Inheritance diagram for lunchbox::SpinLock:
+ Collaboration diagram for lunchbox::SpinLock:

List of all members.

Public Member Functions

 SpinLock ()
 Construct a new lock.
 ~SpinLock ()
 Destruct the lock.
void set ()
 Acquire the lock exclusively.
void unset ()
 Release an exclusive lock.
bool trySet ()
 Attempt to acquire the lock exclusively.
void setRead ()
 Acquire the lock shared with other readers.
void unsetRead ()
 Release a shared read lock.
bool trySetRead ()
 Attempt to acquire the lock shared with other readers.
bool isSet ()
 Test if the lock is set.
bool isSetWrite ()
 Test if the lock is set exclusively.
bool isSetRead ()
 Test if the lock is set shared.

Detailed Description

A fast lock for uncontended memory access.

If Thread::yield does not work like expected, priority inversion is possible. If used as a read-write lock, readers or writers will starve on high contention.

See also:
ScopedMutex

Definition at line 38 of file spinLock.h.


Constructor & Destructor Documentation

Construct a new lock.

Version:
1.0

Destruct the lock.

Version:
1.0

Member Function Documentation

Test if the lock is set.

Returns:
true if the lock is set, false if it is not set.
Version:
1.0

Test if the lock is set shared.

Returns:
true if the lock is set, false if it is not set.
Version:
1.1.2

Test if the lock is set exclusively.

Returns:
true if the lock is set, false if it is not set.
Version:
1.1.2

Acquire the lock exclusively.

Version:
1.0

Acquire the lock shared with other readers.

Version:
1.1.2

Attempt to acquire the lock exclusively.

Returns:
true if the lock was set, false if it was not set.
Version:
1.0

Attempt to acquire the lock shared with other readers.

Returns:
true if the lock was set, false if it was not set.
Version:
1.1.2

Release an exclusive lock.

Version:
1.0

Release a shared read lock.

Version:
1.1.2

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