BloombergLP::bsls::AtomicBool::testAndSwap

Conditionally swap this value if it equals compareValue.

Synopsis

Declared in <bsls_atomic.h>

bool
testAndSwap(
    bool compareValue,
    bool swapValue);

Description

Compare the value of this object to the specified compareValue. If they are equal, set the value of this atomic boolean to the specified swapValue, otherwise leave this value unchanged. Return the previous value of this atomic boolean, whether or not the swap occurred. Note that the entire test-and-swap operation is performed atomically.

Return Value

previous value of this object

Parameters

NameDescription
compareValueexpected current value of this object
swapValuevalue to store if the comparison succeeds