atomicPointerCompareAndExchangeFull

fnbool atomicPointerCompareAndExchangeFull(void * atomic, void * oldval, void * newval, out void * 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 [glib.global.atomicPointerCompareAndExchange]

Parameters

atomica pointer to a #gpointer-sized value
oldvalthe value to compare with
newvalthe value to conditionally replace with
prevalthe contents of atomic before this operation

Returns

true if the exchange took place