SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWAtomicFlag Class Reference

Atomically sets and clears a bit flag. More...

#include <rw/tools/atomicflag.h>

Public Member Functions

void clear (RWAtomicMemoryOrder order=rw_mem_order_seq_cst)
 
void clear (RWAtomicMemoryOrder order=rw_mem_order_seq_cst) volatile
 
bool testAndSet (RWAtomicMemoryOrder order=rw_mem_order_seq_cst)
 
bool testAndSet (RWAtomicMemoryOrder order=rw_mem_order_seq_cst) volatile
 

Related Symbols

(Note that these are not member symbols.)

#define RW_ATOMIC_FLAG_INIT
 

Detailed Description

RWAtomicFlag manages a bit flag (set or cleared) allowing for atomic manipulation of the bit, including providing test-and-set functionality.

Example
while (!flag.testAndSet()) {
// ...
}
// ...
flag.clear();
Atomically sets and clears a bit flag.
Definition atomicflag.h:69
#define RW_ATOMIC_FLAG_INIT
Definition atomicflag.h:38
bool testAndSet(RWAtomicMemoryOrder order=rw_mem_order_seq_cst)
Definition atomicflag.h:75
void clear(RWAtomicMemoryOrder order=rw_mem_order_seq_cst)
Definition atomicflag.h:95

Note
While copy construction and assignment are not prohibited, these operations are not performed in an atomic manner, and may result in undefined behavior. These operations may be prohibited in a future release and should be avoided.

Member Function Documentation

◆ clear() [1/2]

void RWAtomicFlag::clear ( RWAtomicMemoryOrder order = rw_mem_order_seq_cst)
inline

Unsets the flag.

Note
order values of rw_mem_order_consume, rw_mem_order_acquire and rw_mem_order_acq_rel are not supported and will result in undefined behavior.

◆ clear() [2/2]

void RWAtomicFlag::clear ( RWAtomicMemoryOrder order = rw_mem_order_seq_cst) volatile
inline

Unsets the flag.

Note
order values of rw_mem_order_consume, rw_mem_order_acquire and rw_mem_order_acq_rel are not supported and will result in undefined behavior.

◆ testAndSet() [1/2]

bool RWAtomicFlag::testAndSet ( RWAtomicMemoryOrder order = rw_mem_order_seq_cst)
inline

Sets the flag and returns true if the flag was previously set, false otherwise.

◆ testAndSet() [2/2]

bool RWAtomicFlag::testAndSet ( RWAtomicMemoryOrder order = rw_mem_order_seq_cst) volatile
inline

Sets the flag and returns true if the flag was previously set, false otherwise.

Friends And Related Symbol Documentation

◆ RW_ATOMIC_FLAG_INIT

#define RW_ATOMIC_FLAG_INIT
related

Initializes an RWAtomicFlag to a cleared state.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.