Function
GLibatomic_int_compare_and_exchange_full
since: 2.74
Declaration [src]
gboolean
g_atomic_int_compare_and_exchange_full (
gint* atomic,
gint oldval,
gint newval,
gint* preval
)
Description [src]
Compares atomic
to oldval
and, if equal, sets it to newval
.
If atomic
was not equal to oldval
then no change occurs.
In any case the value of atomic
before this operation is stored in preval
.
This compare and exchange is done atomically.
Think of this operation as an atomic version of
{ *preval = *atomic; if (*atomic == oldval) { *atomic = newval; return TRUE; } else return FALSE; }
.
This call acts as a full compiler and hardware memory barrier.
See also g_atomic_int_compare_and_exchange().
Available since: 2.74
Parameters
atomic
-
Type:
gint*
A pointer to a #gint or #guint.
The data is owned by the caller of the function. oldval
-
Type:
gint
The value to compare with.
newval
-
Type:
gint
The value to conditionally replace with.
preval
-
Type:
gint*
The contents of
atomic
before this operation.The argument will be set by the function.