Interface Atomics

    interface Atomics {
        [toStringTag]: "Atomics";
        add(typedArray:
            | Int8Array
            | Uint8Array
            | Int16Array
            | Uint16Array
            | Int32Array
            | Uint32Array, index: number, value: number): number;
        add(typedArray: BigInt64Array | BigUint64Array, index: number, value: bigint): bigint;
        and(typedArray:
            | Int8Array
            | Uint8Array
            | Int16Array
            | Uint16Array
            | Int32Array
            | Uint32Array, index: number, value: number): number;
        and(typedArray: BigInt64Array | BigUint64Array, index: number, value: bigint): bigint;
        compareExchange(typedArray:
            | Int8Array
            | Uint8Array
            | Int16Array
            | Uint16Array
            | Int32Array
            | Uint32Array, index: number, expectedValue: number, replacementValue: number): number;
        compareExchange(typedArray: BigInt64Array | BigUint64Array, index: number, expectedValue: bigint, replacementValue: bigint): bigint;
        exchange(typedArray:
            | Int8Array
            | Uint8Array
            | Int16Array
            | Uint16Array
            | Int32Array
            | Uint32Array, index: number, value: number): number;
        exchange(typedArray: BigInt64Array | BigUint64Array, index: number, value: bigint): bigint;
        isLockFree(size: number): boolean;
        load(typedArray:
            | Int8Array
            | Uint8Array
            | Int16Array
            | Uint16Array
            | Int32Array
            | Uint32Array, index: number): number;
        load(typedArray: BigInt64Array | BigUint64Array, index: number): bigint;
        notify(typedArray: Int32Array, index: number, count?: number): number;
        notify(typedArray: BigInt64Array, index: number, count?: number): number;
        or(typedArray:
            | Int8Array
            | Uint8Array
            | Int16Array
            | Uint16Array
            | Int32Array
            | Uint32Array, index: number, value: number): number;
        or(typedArray: BigInt64Array | BigUint64Array, index: number, value: bigint): bigint;
        store(typedArray:
            | Int8Array
            | Uint8Array
            | Int16Array
            | Uint16Array
            | Int32Array
            | Uint32Array, index: number, value: number): number;
        store(typedArray: BigInt64Array | BigUint64Array, index: number, value: bigint): bigint;
        sub(typedArray:
            | Int8Array
            | Uint8Array
            | Int16Array
            | Uint16Array
            | Int32Array
            | Uint32Array, index: number, value: number): number;
        sub(typedArray: BigInt64Array | BigUint64Array, index: number, value: bigint): bigint;
        wait(typedArray: Int32Array, index: number, value: number, timeout?: number): "ok" | "not-equal" | "timed-out";
        wait(typedArray: BigInt64Array, index: number, value: bigint, timeout?: number): "ok" | "not-equal" | "timed-out";
        waitAsync(typedArray: Int32Array, index: number, value: number, timeout?: number): {
            async: false;
            value: "not-equal" | "timed-out";
        } | {
            async: true;
            value: Promise<"ok" | "timed-out">;
        };
        waitAsync(typedArray: BigInt64Array, index: number, value: bigint, timeout?: number): {
            async: false;
            value: "not-equal" | "timed-out";
        } | {
            async: true;
            value: Promise<"ok" | "timed-out">;
        };
        xor(typedArray:
            | Int8Array
            | Uint8Array
            | Int16Array
            | Uint16Array
            | Int32Array
            | Uint32Array, index: number, value: number): number;
        xor(typedArray: BigInt64Array | BigUint64Array, index: number, value: bigint): bigint;
    }

    Properties

    [toStringTag]: "Atomics"

    Methods

    • Adds a value to the value at the given position in the array, returning the original value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns number

    • Adds a value to the value at the given position in the array, returning the original value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns bigint

    • Stores the bitwise AND of a value with the value at the given position in the array, returning the original value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns number

    • Stores the bitwise AND of a value with the value at the given position in the array, returning the original value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns bigint

    • Replaces the value at the given position in the array if the original value equals the given expected value, returning the original value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns number

    • Replaces the value at the given position in the array if the original value equals the given expected value, returning the original value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns bigint

    • Replaces the value at the given position in the array, returning the original value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns number

    • Replaces the value at the given position in the array, returning the original value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns bigint

    • Returns a value indicating whether high-performance algorithms can use atomic operations (true) or must use locks (false) for the given number of bytes-per-element of a typed array.

      Parameters

      • size: number

      Returns boolean

    • Returns the value at the given position in the array. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns number

    • Returns the value at the given position in the array. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns bigint

    • Wakes up sleeping agents that are waiting on the given index of the array, returning the number of agents that were awoken.

      Parameters

      • typedArray: Int32Array

        A shared Int32Array.

      • index: number

        The position in the typedArray to wake up on.

      • Optionalcount: number

        The number of sleeping agents to notify. Defaults to +Infinity.

      Returns number

    • Wakes up sleeping agents that are waiting on the given index of the array, returning the number of agents that were awoken.

      Parameters

      • typedArray: BigInt64Array

        A shared BigInt64Array.

      • index: number

        The position in the typedArray to wake up on.

      • Optionalcount: number

        The number of sleeping agents to notify. Defaults to +Infinity.

      Returns number

    • Stores the bitwise OR of a value with the value at the given position in the array, returning the original value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns number

    • Stores the bitwise OR of a value with the value at the given position in the array, returning the original value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns bigint

    • Stores a value at the given position in the array, returning the new value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns number

    • Stores a value at the given position in the array, returning the new value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns bigint

    • Subtracts a value from the value at the given position in the array, returning the original value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns number

    • Subtracts a value from the value at the given position in the array, returning the original value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns bigint

    • If the value at the given position in the array is equal to the provided value, the current agent is put to sleep causing execution to suspend until the timeout expires (returning "timed-out") or until the agent is awoken (returning "ok"); otherwise, returns "not-equal".

      Parameters

      • typedArray: Int32Array
      • index: number
      • value: number
      • Optionaltimeout: number

      Returns "ok" | "not-equal" | "timed-out"

    • If the value at the given position in the array is equal to the provided value, the current agent is put to sleep causing execution to suspend until the timeout expires (returning "timed-out") or until the agent is awoken (returning "ok"); otherwise, returns "not-equal".

      Parameters

      • typedArray: BigInt64Array
      • index: number
      • value: bigint
      • Optionaltimeout: number

      Returns "ok" | "not-equal" | "timed-out"

    • A non-blocking, asynchronous version of wait which is usable on the main thread. Waits asynchronously on a shared memory location and returns a Promise

      Parameters

      • typedArray: Int32Array

        A shared Int32Array or BigInt64Array.

      • index: number

        The position in the typedArray to wait on.

      • value: number

        The expected value to test.

      • Optionaltimeout: number

        The expected value to test.

      Returns {
          async: false;
          value: "not-equal" | "timed-out";
      } | {
          async: true;
          value: Promise<"ok" | "timed-out">;
      }

    • A non-blocking, asynchronous version of wait which is usable on the main thread. Waits asynchronously on a shared memory location and returns a Promise

      Parameters

      • typedArray: BigInt64Array

        A shared Int32Array or BigInt64Array.

      • index: number

        The position in the typedArray to wait on.

      • value: bigint

        The expected value to test.

      • Optionaltimeout: number

        The expected value to test.

      Returns {
          async: false;
          value: "not-equal" | "timed-out";
      } | {
          async: true;
          value: Promise<"ok" | "timed-out">;
      }

    • Stores the bitwise XOR of a value with the value at the given position in the array, returning the original value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns number

    • Stores the bitwise XOR of a value with the value at the given position in the array, returning the original value. Until this atomic operation completes, any other read or write operation against the array will block.

      Parameters

      Returns bigint