Function

GLib-2.0GLibatomic_pointer_compare_and_exchange_fullSince 2.74

  • 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_pointer_compare_and_exchange()

    Parameters

    • atomic: any

      a pointer to a gpointer-sized value

    • oldval: any

      the value to compare with

    • newval: any

      the value to conditionally replace with

    Returns [boolean, any]

    true if the exchange took place

    2.74