[#BloombergLP-bsls-AtomicBool-testAndSwapAcqRel]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::xref:BloombergLP/bsls/AtomicBool.adoc[AtomicBool]::testAndSwapAcqRel
:relfileprefix: ../../../
:mrdocs:

Conditionally swap this value with acquire&sol;release ordering&period;

== Synopsis

Declared in `&lt;bsls&lowbar;atomic&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
bool
testAndSwapAcqRel(
    bool compareValue,
    bool swapValue);
----

== Description

Compare the value of this object to the specified `compareValue`&period; If they are equal, set the value of this atomic boolean to the specified `swapValue`, otherwise leave this value unchanged&period; Return the previous value of this atomic boolean, whether or not the swap occurred&period; Note that the entire test&hyphen;and&hyphen;swap operation is performed atomically and it provides the acquire&sol;release memory ordering guarantee&period;

== Return Value

previous value of this object

== Parameters

[cols="1,4"]
|===
| Name| Description
| *compareValue*
| expected current value of this object
| *swapValue*
| value to store if the comparison succeeds
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
