Jamba  3.0.2
SpinLock Class Reference

#include <SpinLock.h>

Classes

class  Lock
 

Public Member Functions

Lock acquire ()
 
SpinLockoperator= (SpinLock const &)=delete
 
 SpinLock ()
 
 SpinLock (SpinLock const &)=delete
 

Private Member Functions

void unlock ()
 

Private Attributes

std::atomic_flag fFlag
 

Friends

class Lock
 

Detailed Description

A simple implementation of a spin lock using the std::atomic_flag which is guaranteed to be atomic and lock free. The usage is the following:

auto lock = spinLock.acquire(); ...

the lock is released automatically when it exits the scope.

Constructor & Destructor Documentation

◆ SpinLock() [1/2]

SpinLock::SpinLock ( )
inline

◆ SpinLock() [2/2]

SpinLock::SpinLock ( SpinLock const &  )
delete

Member Function Documentation

◆ acquire()

Lock SpinLock::acquire ( )
inline
Returns
the lock that will be released when it goes out of scope

◆ operator=()

SpinLock& SpinLock::operator= ( SpinLock const &  )
delete

◆ unlock()

void SpinLock::unlock ( )
inlineprivate

Friends And Related Function Documentation

◆ Lock

friend class Lock
friend

Member Data Documentation

◆ fFlag

std::atomic_flag SpinLock::fFlag
private

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