Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
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

◆ 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: