Thea
|
A simple lock that can be shared by multiple threads for synchronization. More...
#include <Spinlock.hpp>
Public Member Functions | |
void | lock () |
Acquire the lock by atomically setting the value of an integer to non-zero, busy-waiting until the lock is obtained. More... | |
Spinlock () | |
Constructor. More... | |
void | unlock () |
Release the lock by atomically setting the value of an integer to zero. More... | |
A simple lock that can be shared by multiple threads for synchronization.
Busy-waits for a lock, and unlocks immediately. Implemented with a single atomic integer.
Definition at line 26 of file Spinlock.hpp.
Spinlock | ( | ) |
void lock | ( | ) |
Acquire the lock by atomically setting the value of an integer to non-zero, busy-waiting until the lock is obtained.
Definition at line 37 of file Spinlock.hpp.
void unlock | ( | ) |
Release the lock by atomically setting the value of an integer to zero.
This operation is immediate and does not wait.
Definition at line 47 of file Spinlock.hpp.