Jamba C++ API  5.1.1
SpinLock Class Reference

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

#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 ( )
inline

◆ SpinLock() [2/2]

SpinLock ( SpinLock const &  )
delete

Member Function Documentation

◆ acquire()

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

◆ operator=()

SpinLock& operator= ( SpinLock const &  )
delete

◆ unlock()

void unlock ( )
inlineprivate

Friends And Related Function Documentation

◆ Lock

friend class Lock
friend

Member Data Documentation

◆ fFlag

std::atomic_flag fFlag
private

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