compare And Swap Values
abstract fun compareAndSwapValues(reference: A_BasicObject, newValue: A_BasicObject): Boolean
Content copied to clipboard
Read the variable's value, compare it to a reference value via semantic equality, and if they're equal, store a provided new value into the variable and answer true. Otherwise answer false. If the variable is potentially shared, then ensure suitable locks bracket this entire sequence of operations.
Return
Whether the replacement took place.
Parameters
reference
The value to compare against the variable's current value.
new Value
The replacement value to store if the reference value is equal to the variable's old value.
Throws
If the current value could not be read, e.g., because the variable is unassigned.
If the new value is incorrectly typed.