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, index, value): number
Parameters
- typedArray:
| Int8Array
| Uint8Array
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array - index: number
- value: number
Returns number
- typedArray:
- add(typedArray, index, value): 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, index, value): 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
- typedArray:
- and(typedArray, index, value): 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
- compare
Exchange (typedArray, index, expectedValue, replacementValue): 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
- typedArray:
- compare
Exchange (typedArray, index, expectedValue, replacementValue): 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, index, value): 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
- typedArray:
- exchange(typedArray, index, value): 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, index): 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
- typedArray:
- load(typedArray, index): 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, index, count?): 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: Int32Array
A shared Int32Array.
- index: number
The position in the typedArray to wake up on.
Optional
count: numberThe number of sleeping agents to notify. Defaults to +Infinity.
Returns number
- typedArray: Int32Array
- notify(typedArray, index, count?): 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.
Optional
count: numberThe number of sleeping agents to notify. Defaults to +Infinity.
Returns number
- typedArray: BigInt64Array
or
- or(typedArray, index, value): 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
- typedArray:
- or(typedArray, index, value): 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, index, value): 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
- typedArray:
- store(typedArray, index, value): 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, index, value): 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
- typedArray:
- sub(typedArray, index, value): 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, index, value, timeout?): "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
Optional
timeout: number
Returns "ok" | "not-equal" | "timed-out"
- wait(typedArray, index, value, timeout?): "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
Optional
timeout: number
Returns "ok" | "not-equal" | "timed-out"
waitAsync
- wait
Async (typedArray, index, value, timeout?): {
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: Int32Array
A shared Int32Array or BigInt64Array.
- index: number
The position in the typedArray to wait on.
- value: number
The expected value to test.
Optional
timeout: numberThe expected value to test.
Returns {
async: false;
value: "not-equal" | "timed-out";
} | {
async: true;
value: Promise<"ok" | "timed-out">;
}- typedArray: Int32Array
- wait
Async (typedArray, index, value, timeout?): {
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.
Optional
timeout: numberThe expected value to test.
Returns {
async: false;
value: "not-equal" | "timed-out";
} | {
async: true;
value: Promise<"ok" | "timed-out">;
}- typedArray: BigInt64Array
xor
- xor(typedArray, index, value): 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
- typedArray:
- xor(typedArray, index, value): 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.