Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::TSpinMutex Class Reference

A spin mutex class which respects the STL interface for mutexes.

This class allows to acquire spin locks also in combination with templates in the STL such as std::unique_lock or std::condition_variable_any. For example:

std::condition_variable cv;
bool ready = false;
{
// Wait until main() sends data
std::unique_lock<ROOT::TSpinMutex> lk(m);
cv.wait(lk, []{return ready;});
[...]
}
static void * worker_thread(void *thread_func_param)
Definition civetweb.c:19086
A spin mutex class which respects the STL interface for mutexes.
TMarker m
Definition textangle.C:8

{.cpp}

Definition at line 42 of file TSpinMutex.hxx.

Public Member Functions

 TSpinMutex ()=default
 
 TSpinMutex (const TSpinMutex &)=delete
 
 ~TSpinMutex ()=default
 
void lock ()
 
TSpinMutexoperator= (const TSpinMutex &)=delete
 
bool try_lock ()
 
void unlock ()
 

Private Attributes

std::atomic_flag fAFlag = ATOMIC_FLAG_INIT
 

#include <ROOT/TSpinMutex.hxx>

Constructor & Destructor Documentation

◆ TSpinMutex() [1/2]

ROOT::TSpinMutex::TSpinMutex ( )
default

◆ TSpinMutex() [2/2]

ROOT::TSpinMutex::TSpinMutex ( const TSpinMutex )
delete

◆ ~TSpinMutex()

ROOT::TSpinMutex::~TSpinMutex ( )
default

Member Function Documentation

◆ lock()

void ROOT::TSpinMutex::lock ( )
inline

Definition at line 53 of file TSpinMutex.hxx.

◆ operator=()

TSpinMutex & ROOT::TSpinMutex::operator= ( const TSpinMutex )
delete

◆ try_lock()

bool ROOT::TSpinMutex::try_lock ( )
inline

Definition at line 55 of file TSpinMutex.hxx.

◆ unlock()

void ROOT::TSpinMutex::unlock ( )
inline

Definition at line 54 of file TSpinMutex.hxx.

Member Data Documentation

◆ fAFlag

std::atomic_flag ROOT::TSpinMutex::fAFlag = ATOMIC_FLAG_INIT
private

Definition at line 45 of file TSpinMutex.hxx.

Libraries for ROOT::TSpinMutex:

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