sycamore::web::js_sys::Atomics

Function compare_exchange

source
pub fn compare_exchange(
    typed_array: &JsValue,
    index: u32,
    expected_value: i32,
    replacement_value: i32,
) -> Result<i32, JsValue>
Expand description

The static Atomics.compareExchange() method exchanges a given replacement value at a given position in the array, if a given expected value equals the old value. It returns the old value at that position whether it was equal to the expected value or not. This atomic operation guarantees that no other write happens until the modified value is written back.

You should use compare_exchange_bigint to operate on a BigInt64Array or a BigUint64Array.

MDN documentation