atomic_compare_exchange_strong (C11)

Purpose

Performs an atomic compare and exchange operation.

Prototypes

_Bool atomic_compare_exchange_strong(volatile A *object, C *expected, C desired);

Parameters

A
One of the atomic types.
C
The corresponding non-atomic type of A.
object
A pointer that points to the atomic object to test and modify.
expected
A pointer that points to the value expected to be found in the atomic object.
desired
The value to be stored in the atomic object if the comparison result is true.

Usage

This function atomically compares the value pointed to by object for equality with the value pointed to by expected.

If the comparison result is true, this function replaces the value pointed to by object with desired.

If the comparison result is false, this function updates the value pointed to by expected with the value pointed to by object.

Return value

Returns the result of the comparison.