The Atomics object provides atomic operations as static methods. They are used with SharedArrayBuffer objects.
The static Atomics.add() method adds a given value at a given position in the array and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back.
The static Atomics.and() method computes a bitwise AND with a given value at a given position in the array, and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back.
The static Atomics.compareExchange() method exchanges a given replacement value at a given position in the array, and returns the old value at that position, if a given expected value equals the old value. This atomic operation guarantees that no other write happens until the modified value is written back.
The static Atomics.exchange() method exchanges a given value at a given position in the array and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back.
The static Atomics.isLockFree() method is used to determine whether to use locks or atomic operations. It returns true, if the given size is one of the BYTES_PER_ELEMENT property of integer TypedArray types.
The static Atomics.load() method returns a value at a given position in the array. This atomic operation guarantees that no other read happens until the modified value is read back.
The static Atomics.or() method computes a bitwise OR with a given value at a given position in the array, and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back.
The static Atomics.store() method stores a given value at the given position in the array and returns that value. This atomic operation guarantees that no other write happens until the modified value is written back.
The static Atomics.sub() method substracts a given value at a given position in the array and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back.
The static Atomics.wait() method verifies that a given position in an Int32Array still contains a given value and sleeps awaiting or times out. It returns a string which is either "ok", "not-equal", or "timed-out".
The static Atomics.wake() method wakes up some agents that are sleeping in the wait queue.
The static Atomics.xor() method computes a bitwise XOR with a given value at a given position in the array, and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back.
The SharedArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer, similar to the ArrayBuffer object, but in a way that they can be used to create views on shared memory. Unlike an ArrayBuffer, a SharedArrayBuffer cannot become detached.
The SharedArrayBuffer.prototype property represents the prototype for the SharedArrayBuffer object.