Thea
Public Member Functions | List of all members
Spinlock Class Reference

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

Detailed Description

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.

Constructor & Destructor Documentation

Spinlock ( )

Constructor.

The object is initially unlocked.

Definition at line 30 of file Spinlock.hpp.

Member Function Documentation

void lock ( )

Acquire the lock by atomically setting the value of an integer to non-zero, busy-waiting until the lock is obtained.

See also
unlock()

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.

See also
unlock()

Definition at line 47 of file Spinlock.hpp.


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