1 /*! *****************************************************************************
2 Copyright (c) Microsoft Corporation. All rights reserved.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the
5 License at http://www.apache.org/licenses/LICENSE-2.0
7 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10 MERCHANTABLITY OR NON-INFRINGEMENT.
12 See the Apache Version 2.0 License for specific language governing permissions
13 and limitations under the License.
14 ***************************************************************************** */
18 /// <reference no-default-lib="true"/>
\r
21 /// <reference lib="es2015.symbol" />
\r
22 /// <reference lib="es2015.symbol.wellknown" />
\r
24 interface SharedArrayBuffer {
\r
26 * Read-only. The length of the ArrayBuffer (in bytes).
\r
28 readonly byteLength: number;
\r
31 * Returns a section of an SharedArrayBuffer.
\r
33 slice(begin: number, end?: number): SharedArrayBuffer;
\r
34 readonly [Symbol.species]: SharedArrayBuffer;
\r
35 readonly [Symbol.toStringTag]: "SharedArrayBuffer";
\r
38 interface SharedArrayBufferConstructor {
\r
39 readonly prototype: SharedArrayBuffer;
\r
40 new (byteLength: number): SharedArrayBuffer;
\r
42 declare var SharedArrayBuffer: SharedArrayBufferConstructor;
\r
44 interface ArrayBufferTypes {
\r
45 SharedArrayBuffer: SharedArrayBuffer;
\r
50 * Adds a value to the value at the given position in the array, returning the original value.
\r
51 * Until this atomic operation completes, any other read or write operation against the array
\r
54 add(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
\r
57 * Stores the bitwise AND of a value with the value at the given position in the array,
\r
58 * returning the original value. Until this atomic operation completes, any other read or
\r
59 * write operation against the array will block.
\r
61 and(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
\r
64 * Replaces the value at the given position in the array if the original value equals the given
\r
65 * expected value, returning the original value. Until this atomic operation completes, any
\r
66 * other read or write operation against the array will block.
\r
68 compareExchange(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, expectedValue: number, replacementValue: number): number;
\r
71 * Replaces the value at the given position in the array, returning the original value. Until
\r
72 * this atomic operation completes, any other read or write operation against the array will
\r
75 exchange(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
\r
78 * Returns a value indicating whether high-performance algorithms can use atomic operations
\r
79 * (`true`) or must use locks (`false`) for the given number of bytes-per-element of a typed
\r
82 isLockFree(size: number): boolean;
\r
85 * Returns the value at the given position in the array. Until this atomic operation completes,
\r
86 * any other read or write operation against the array will block.
\r
88 load(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number): number;
\r
91 * Stores the bitwise OR of a value with the value at the given position in the array,
\r
92 * returning the original value. Until this atomic operation completes, any other read or write
\r
93 * operation against the array will block.
\r
95 or(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
\r
98 * Stores a value at the given position in the array, returning the new value. Until this
\r
99 * atomic operation completes, any other read or write operation against the array will block.
\r
101 store(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
\r
104 * Subtracts a value from the value at the given position in the array, returning the original
\r
105 * value. Until this atomic operation completes, any other read or write operation against the
\r
106 * array will block.
\r
108 sub(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
\r
111 * If the value at the given position in the array is equal to the provided value, the current
\r
112 * agent is put to sleep causing execution to suspend until the timeout expires (returning
\r
113 * `"timed-out"`) or until the agent is awoken (returning `"ok"`); otherwise, returns
\r
116 wait(typedArray: Int32Array, index: number, value: number, timeout?: number): "ok" | "not-equal" | "timed-out";
\r
119 * Wakes up sleeping agents that are waiting on the given index of the array, returning the
\r
120 * number of agents that were awoken.
\r
121 * @param typedArray A shared Int32Array.
\r
122 * @param index The position in the typedArray to wake up on.
\r
123 * @param count The number of sleeping agents to notify. Defaults to +Infinity.
\r
125 notify(typedArray: Int32Array, index: number, count?: number): number;
\r
128 * Stores the bitwise XOR of a value with the value at the given position in the array,
\r
129 * returning the original value. Until this atomic operation completes, any other read or write
\r
130 * operation against the array will block.
\r
132 xor(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
\r
134 readonly [Symbol.toStringTag]: "Atomics";
\r
137 declare var Atomics: Atomics;
\r