SourcePro® API Reference Guide

Product Documentation:
   SourcePro
Documentation Home
List of all members | Public Member Functions | Related Functions
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 Functions

(Note that these are not member functions.)

#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();

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

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.
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.
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.

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 Function Documentation

#define RW_ATOMIC_FLAG_INIT
related

Initializes an RWAtomicFlag to a cleared state.

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