compareAndSwapValues

open override fun compareAndSwapValues(reference: A_BasicObject, newValue: A_BasicObject): Boolean

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.

newValue

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.