compare_and_exchange_full


Description:

[ Version ( since = "2.74" ) ]
[ CCode ( cname = "g_atomic_int_compare_and_exchange_full" ) ]
public bool compare_and_exchange_full (ref uint atomic, uint oldval, uint newval, out uint preval)

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 compare_and_exchange

Parameters:

atomic

a pointer to a int or uint

oldval

the value to compare with

newval

the value to conditionally replace with

preval

the contents of atomic before this operation

Returns:

true if the exchange took place


Namespace: GLib.AtomicUint
Package: glib-2.0