compareAndExchange method

T compareAndExchange(
  1. T expectedValue,
  2. T newValue
)

Atomically sets the value to the given newValue if the current value equals the expectedValue and returns the old value in any case.

Implementation

external T compareAndExchange(T expectedValue, T newValue);