Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
kcenon::thread::sync::atomic_flag_wrapper Class Reference

Enhanced atomic flag with additional operations. More...

#include <sync_primitives.h>

Collaboration diagram for kcenon::thread::sync::atomic_flag_wrapper:
Collaboration graph

Public Member Functions

 atomic_flag_wrapper () noexcept
 
 ~atomic_flag_wrapper ()=default
 
 atomic_flag_wrapper (const atomic_flag_wrapper &)=delete
 
atomic_flag_wrapperoperator= (const atomic_flag_wrapper &)=delete
 
 atomic_flag_wrapper (atomic_flag_wrapper &&)=default
 
atomic_flag_wrapperoperator= (atomic_flag_wrapper &&)=default
 
bool test_and_set (std::memory_order order=std::memory_order_acq_rel) noexcept
 Test and set the flag atomically.
 
void clear (std::memory_order order=std::memory_order_release) noexcept
 Clear the flag atomically.
 
bool test (std::memory_order order=std::memory_order_acquire) const noexcept
 Test the flag without modifying it.
 
void wait (bool expected, std::memory_order order=std::memory_order_acquire) const noexcept
 Wait until the flag becomes false.
 
void notify_one () noexcept
 Notify one thread waiting on this flag.
 
void notify_all () noexcept
 Notify all threads waiting on this flag.
 
 atomic_flag_wrapper () noexcept
 
 ~atomic_flag_wrapper ()=default
 
 atomic_flag_wrapper (const atomic_flag_wrapper &)=delete
 
atomic_flag_wrapperoperator= (const atomic_flag_wrapper &)=delete
 
 atomic_flag_wrapper (atomic_flag_wrapper &&)=default
 
atomic_flag_wrapperoperator= (atomic_flag_wrapper &&)=default
 
bool test_and_set (std::memory_order order=std::memory_order_acq_rel) noexcept
 Test and set the flag atomically.
 
void clear (std::memory_order order=std::memory_order_release) noexcept
 Clear the flag atomically.
 
bool test (std::memory_order order=std::memory_order_acquire) const noexcept
 Test the flag without modifying it.
 
void wait (bool expected, std::memory_order order=std::memory_order_acquire) const noexcept
 Wait until the flag becomes false.
 
void notify_one () noexcept
 Notify one thread waiting on this flag.
 
void notify_all () noexcept
 Notify all threads waiting on this flag.
 

Private Attributes

std::atomic_flag flag_
 

Detailed Description

Enhanced atomic flag with additional operations.

Definition at line 170 of file sync_primitives.h.

Constructor & Destructor Documentation

◆ atomic_flag_wrapper() [1/6]

kcenon::thread::sync::atomic_flag_wrapper::atomic_flag_wrapper ( )
inlinenoexcept

Definition at line 166 of file sync_primitives.h.

166: flag_(ATOMIC_FLAG_INIT) {}

◆ ~atomic_flag_wrapper() [1/2]

kcenon::thread::sync::atomic_flag_wrapper::~atomic_flag_wrapper ( )
default

◆ atomic_flag_wrapper() [2/6]

kcenon::thread::sync::atomic_flag_wrapper::atomic_flag_wrapper ( const atomic_flag_wrapper & )
delete

◆ atomic_flag_wrapper() [3/6]

kcenon::thread::sync::atomic_flag_wrapper::atomic_flag_wrapper ( atomic_flag_wrapper && )
default

◆ atomic_flag_wrapper() [4/6]

kcenon::thread::sync::atomic_flag_wrapper::atomic_flag_wrapper ( )
inlinenoexcept

Definition at line 172 of file sync_primitives.h.

172: flag_(ATOMIC_FLAG_INIT) {}

◆ ~atomic_flag_wrapper() [2/2]

kcenon::thread::sync::atomic_flag_wrapper::~atomic_flag_wrapper ( )
default

◆ atomic_flag_wrapper() [5/6]

kcenon::thread::sync::atomic_flag_wrapper::atomic_flag_wrapper ( const atomic_flag_wrapper & )
delete

◆ atomic_flag_wrapper() [6/6]

kcenon::thread::sync::atomic_flag_wrapper::atomic_flag_wrapper ( atomic_flag_wrapper && )
default

Member Function Documentation

◆ clear() [1/2]

void kcenon::thread::sync::atomic_flag_wrapper::clear ( std::memory_order order = std::memory_order_release)
inlinenoexcept

Clear the flag atomically.

Parameters
orderMemory ordering constraint

Definition at line 188 of file sync_primitives.h.

188 {
189 flag_.clear(order);
190 }

References flag_.

◆ clear() [2/2]

void kcenon::thread::sync::atomic_flag_wrapper::clear ( std::memory_order order = std::memory_order_release)
inlinenoexcept

Clear the flag atomically.

Parameters
orderMemory ordering constraint

Definition at line 194 of file sync_primitives.h.

194 {
195 flag_.clear(order);
196 }

References flag_.

◆ notify_all() [1/2]

void kcenon::thread::sync::atomic_flag_wrapper::notify_all ( )
inlinenoexcept

Notify all threads waiting on this flag.

Definition at line 219 of file sync_primitives.h.

219 {
220 flag_.notify_all();
221 }

References flag_.

◆ notify_all() [2/2]

void kcenon::thread::sync::atomic_flag_wrapper::notify_all ( )
inlinenoexcept

Notify all threads waiting on this flag.

Definition at line 225 of file sync_primitives.h.

225 {
226 flag_.notify_all();
227 }

References flag_.

◆ notify_one() [1/2]

void kcenon::thread::sync::atomic_flag_wrapper::notify_one ( )
inlinenoexcept

Notify one thread waiting on this flag.

Definition at line 212 of file sync_primitives.h.

212 {
213 flag_.notify_one();
214 }

References flag_.

◆ notify_one() [2/2]

void kcenon::thread::sync::atomic_flag_wrapper::notify_one ( )
inlinenoexcept

Notify one thread waiting on this flag.

Definition at line 218 of file sync_primitives.h.

218 {
219 flag_.notify_one();
220 }

References flag_.

◆ operator=() [1/4]

atomic_flag_wrapper & kcenon::thread::sync::atomic_flag_wrapper::operator= ( atomic_flag_wrapper && )
default

◆ operator=() [2/4]

atomic_flag_wrapper & kcenon::thread::sync::atomic_flag_wrapper::operator= ( atomic_flag_wrapper && )
default

◆ operator=() [3/4]

atomic_flag_wrapper & kcenon::thread::sync::atomic_flag_wrapper::operator= ( const atomic_flag_wrapper & )
delete

◆ operator=() [4/4]

atomic_flag_wrapper & kcenon::thread::sync::atomic_flag_wrapper::operator= ( const atomic_flag_wrapper & )
delete

◆ test() [1/2]

bool kcenon::thread::sync::atomic_flag_wrapper::test ( std::memory_order order = std::memory_order_acquire) const
inlinenoexcept

Test the flag without modifying it.

Parameters
orderMemory ordering constraint
Returns
Current value of the flag

Definition at line 197 of file sync_primitives.h.

197 {
198 return flag_.test(order);
199 }

References flag_.

◆ test() [2/2]

bool kcenon::thread::sync::atomic_flag_wrapper::test ( std::memory_order order = std::memory_order_acquire) const
inlinenoexcept

Test the flag without modifying it.

Parameters
orderMemory ordering constraint
Returns
Current value of the flag

Definition at line 203 of file sync_primitives.h.

203 {
204 return flag_.test(order);
205 }

References flag_.

◆ test_and_set() [1/2]

bool kcenon::thread::sync::atomic_flag_wrapper::test_and_set ( std::memory_order order = std::memory_order_acq_rel)
inlinenoexcept

Test and set the flag atomically.

Parameters
orderMemory ordering constraint
Returns
Previous value of the flag

Definition at line 180 of file sync_primitives.h.

180 {
181 return flag_.test_and_set(order);
182 }

References flag_.

◆ test_and_set() [2/2]

bool kcenon::thread::sync::atomic_flag_wrapper::test_and_set ( std::memory_order order = std::memory_order_acq_rel)
inlinenoexcept

Test and set the flag atomically.

Parameters
orderMemory ordering constraint
Returns
Previous value of the flag

Definition at line 186 of file sync_primitives.h.

186 {
187 return flag_.test_and_set(order);
188 }

References flag_.

◆ wait() [1/2]

void kcenon::thread::sync::atomic_flag_wrapper::wait ( bool expected,
std::memory_order order = std::memory_order_acquire ) const
inlinenoexcept

Wait until the flag becomes false.

Parameters
orderMemory ordering constraint

Definition at line 205 of file sync_primitives.h.

205 {
206 flag_.wait(expected, order);
207 }

References flag_.

◆ wait() [2/2]

void kcenon::thread::sync::atomic_flag_wrapper::wait ( bool expected,
std::memory_order order = std::memory_order_acquire ) const
inlinenoexcept

Wait until the flag becomes false.

Parameters
orderMemory ordering constraint

Definition at line 211 of file sync_primitives.h.

211 {
212 flag_.wait(expected, order);
213 }

References flag_.

Member Data Documentation

◆ flag_

std::atomic_flag kcenon::thread::sync::atomic_flag_wrapper::flag_
private

Definition at line 224 of file sync_primitives.h.

Referenced by clear(), notify_all(), notify_one(), test(), test_and_set(), and wait().


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