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;
}
 Index
Properties
Methods
 Methods
add
- add(
 typedArray:
 | Int8Array
 | Uint8Array
 | Int16Array
 | Uint16Array
 | Int32Array
 | Uint32Array,
 index: number,
 value: number,
 ): number
- Parameters- typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
- index: number
- value: number
 - Returns number
- add(
 typedArray: BigInt64Array | BigUint64Array,
 index: number,
 value: bigint,
 ): bigint
- 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- typedArray: BigInt64Array | BigUint64Array
- index: number
- value: bigint
 - Returns bigint
and
- and(
 typedArray:
 | Int8Array
 | Uint8Array
 | Int16Array
 | Uint16Array
 | Int32Array
 | Uint32Array,
 index: number,
 value: number,
 ): 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- typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
- index: number
- value: number
 - Returns number
- and(
 typedArray: BigInt64Array | BigUint64Array,
 index: number,
 value: bigint,
 ): 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- typedArray: BigInt64Array | BigUint64Array
- index: number
- value: bigint
 - Returns bigint
compareExchange 
- compareExchange(
 typedArray:
 | Int8Array
 | Uint8Array
 | Int16Array
 | Uint16Array
 | Int32Array
 | Uint32Array,
 index: number,
 expectedValue: number,
 replacementValue: number,
 ): 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- typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
- index: number
- expectedValue: number
- replacementValue: number
 - Returns number
- compareExchange(
 typedArray: BigInt64Array | BigUint64Array,
 index: number,
 expectedValue: bigint,
 replacementValue: bigint,
 ): 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- typedArray: BigInt64Array | BigUint64Array
- index: number
- expectedValue: bigint
- replacementValue: bigint
 - Returns bigint
exchange
- exchange(
 typedArray:
 | Int8Array
 | Uint8Array
 | Int16Array
 | Uint16Array
 | Int32Array
 | Uint32Array,
 index: number,
 value: number,
 ): 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- typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
- index: number
- value: number
 - Returns number
- exchange(
 typedArray: BigInt64Array | BigUint64Array,
 index: number,
 value: bigint,
 ): 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- typedArray: BigInt64Array | BigUint64Array
- index: number
- value: bigint
 - Returns bigint
isLockFree  
load
- load(
 typedArray:
 | Int8Array
 | Uint8Array
 | Int16Array
 | Uint16Array
 | Int32Array
 | Uint32Array,
 index: number,
 ): 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- typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
- index: number
 - Returns number
- load(typedArray: BigInt64Array | BigUint64Array, index: number): bigint
- 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- typedArray: BigInt64Array | BigUint64Array
- index: number
 - Returns bigint
notify
- notify(typedArray: Int32Array, index: number, count?: number): 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: Int32ArrayA shared Int32Array . 
- index: numberThe position in the typedArray to wake up on. 
- Optionalcount: number- The number of sleeping agents to notify. Defaults to +Infinity. 
 - Returns number
- typedArray: Int32Array
- notify(typedArray: BigInt64Array, index: number, count?: number): 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: BigInt64ArrayA shared BigInt64Array. 
- index: numberThe position in the typedArray to wake up on. 
- Optionalcount: number- The number of sleeping agents to notify. Defaults to +Infinity. 
 - Returns number
- typedArray: BigInt64Array
or
- or(
 typedArray:
 | Int8Array
 | Uint8Array
 | Int16Array
 | Uint16Array
 | Int32Array
 | Uint32Array,
 index: number,
 value: number,
 ): 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- typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
- index: number
- value: number
 - Returns number
- or(
 typedArray: BigInt64Array | BigUint64Array,
 index: number,
 value: bigint,
 ): bigint
- 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- typedArray: BigInt64Array | BigUint64Array
- index: number
- value: bigint
 - Returns bigint
store
- store(
 typedArray:
 | Int8Array
 | Uint8Array
 | Int16Array
 | Uint16Array
 | Int32Array
 | Uint32Array,
 index: number,
 value: number,
 ): 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- typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
- index: number
- value: number
 - Returns number
- store(
 typedArray: BigInt64Array | BigUint64Array,
 index: number,
 value: bigint,
 ): 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- typedArray: BigInt64Array | BigUint64Array
- index: number
- value: bigint
 - Returns bigint
sub
- sub(
 typedArray:
 | Int8Array
 | Uint8Array
 | Int16Array
 | Uint16Array
 | Int32Array
 | Uint32Array,
 index: number,
 value: number,
 ): 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- typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
- index: number
- value: number
 - Returns number
- sub(
 typedArray: BigInt64Array | BigUint64Array,
 index: number,
 value: bigint,
 ): 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- typedArray: BigInt64Array | BigUint64Array
- index: number
- value: bigint
 - Returns bigint
wait
- wait(
 typedArray: Int32Array,
 index: number,
 value: number,
 timeout?: number,
 ): "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: Int32Array
- index: number
- value: number
- Optionaltimeout: number
 - Returns "ok" | "not-equal" | "timed-out"
- wait(
 typedArray: BigInt64Array,
 index: number,
 value: bigint,
 timeout?: number,
 ): "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"
waitAsync 
- waitAsync(
 typedArray: Int32Array,
 index: number,
 value: number,
 timeout?: number,
 ):
 | { 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: Int32ArrayA shared Int32Array or BigInt64Array. 
- index: numberThe position in the typedArray to wait on. 
- value: numberThe 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"> }
- typedArray: Int32Array
- waitAsync(
 typedArray: BigInt64Array,
 index: number,
 value: bigint,
 timeout?: number,
 ):
 | { 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: BigInt64ArrayA shared Int32Array or BigInt64Array. 
- index: numberThe position in the typedArray to wait on. 
- value: bigintThe 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"> }
- typedArray: BigInt64Array
xor
- xor(
 typedArray:
 | Int8Array
 | Uint8Array
 | Int16Array
 | Uint16Array
 | Int32Array
 | Uint32Array,
 index: number,
 value: number,
 ): 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- typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
- index: number
- value: number
 - Returns number
- xor(
 typedArray: BigInt64Array | BigUint64Array,
 index: number,
 value: bigint,
 ): bigint
- 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- typedArray: BigInt64Array | BigUint64Array
- index: number
- value: bigint
 - Returns bigint
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.