Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
AtomicBoolRAII Class Reference

RAII class for managing the lifetime of an atomic bool. More...

#include <src/utils/concurrency.h>

Public Member Functions

 AtomicBoolRAII (std::atomic< bool > &flag)
 AtomicBoolRAII (const AtomicBoolRAII &)=delete
AtomicBoolRAIIoperator= (const AtomicBoolRAII &)=delete
 AtomicBoolRAII (AtomicBoolRAII &&)=delete
AtomicBoolRAIIoperator= (AtomicBoolRAII &&)=delete

Detailed Description

RAII class for managing the lifetime of an atomic bool.

This class provides a convenient and safe way to manage the lifetime of an atomic bool using the RAII (Resource Acquisition Is Initialization) idiom. When an instance of AtomicBoolRAII is created, it sets the associated atomic bool to true. When the instance goes out of scope, the destructor sets the atomic bool back to false.

Usage example:

std::atomic<bool> flag = false;
void someFunction() {
AtomicBoolRAII raii(flag);
// Do some work while the flag is set to true
}
// After someFunction() returns, the flag is automatically set back to false

Definition at line 33 of file concurrency.h.

Constructor & Destructor Documentation

◆ AtomicBoolRAII()

AtomicBoolRAII::AtomicBoolRAII ( std::atomic< bool > & flag)
inlineexplicit

Definition at line 39 of file concurrency.h.

◆ ~AtomicBoolRAII()

AtomicBoolRAII::~AtomicBoolRAII ( )
inline

Definition at line 44 of file concurrency.h.


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