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
|
6 |
|
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.
|
11 |
|
12 | See the Apache Version 2.0 License for specific language governing permissions
|
13 | and limitations under the License.
|
14 | ***************************************************************************** */
|
15 |
|
16 |
|
17 |
|
18 | /// <reference no-default-lib="true"/>
|
19 |
|
20 |
|
21 | /// <reference lib="es2015.symbol" />
|
22 | /// <reference lib="es2015.symbol.wellknown" />
|
23 |
|
24 | interface SharedArrayBuffer {
|
25 | /**
|
26 | * Read-only. The length of the ArrayBuffer (in bytes).
|
27 | */
|
28 | readonly byteLength: number;
|
29 |
|
30 | /*
|
31 | * The SharedArrayBuffer constructor's length property whose value is 1.
|
32 | */
|
33 | length: number;
|
34 | /**
|
35 | * Returns a section of an SharedArrayBuffer.
|
36 | */
|
37 | slice(begin: number, end?: number): SharedArrayBuffer;
|
38 | readonly [Symbol.species]: SharedArrayBuffer;
|
39 | readonly [Symbol.toStringTag]: "SharedArrayBuffer";
|
40 | }
|
41 |
|
42 | interface SharedArrayBufferConstructor {
|
43 | readonly prototype: SharedArrayBuffer;
|
44 | new (byteLength: number): SharedArrayBuffer;
|
45 | }
|
46 | declare var SharedArrayBuffer: SharedArrayBufferConstructor;
|
47 |
|
48 | interface ArrayBufferTypes {
|
49 | SharedArrayBuffer: SharedArrayBuffer;
|
50 | }
|
51 |
|
52 | interface Atomics {
|
53 | /**
|
54 | * Adds a value to the value at the given position in the array, returning the original value.
|
55 | * Until this atomic operation completes, any other read or write operation against the array
|
56 | * will block.
|
57 | */
|
58 | add(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
59 |
|
60 | /**
|
61 | * Stores the bitwise AND of a value with the value at the given position in the array,
|
62 | * returning the original value. Until this atomic operation completes, any other read or
|
63 | * write operation against the array will block.
|
64 | */
|
65 | and(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
66 |
|
67 | /**
|
68 | * Replaces the value at the given position in the array if the original value equals the given
|
69 | * expected value, returning the original value. Until this atomic operation completes, any
|
70 | * other read or write operation against the array will block.
|
71 | */
|
72 | compareExchange(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, expectedValue: number, replacementValue: number): number;
|
73 |
|
74 | /**
|
75 | * Replaces the value at the given position in the array, returning the original value. Until
|
76 | * this atomic operation completes, any other read or write operation against the array will
|
77 | * block.
|
78 | */
|
79 | exchange(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
80 |
|
81 | /**
|
82 | * Returns a value indicating whether high-performance algorithms can use atomic operations
|
83 | * (`true`) or must use locks (`false`) for the given number of bytes-per-element of a typed
|
84 | * array.
|
85 | */
|
86 | isLockFree(size: number): boolean;
|
87 |
|
88 | /**
|
89 | * Returns the value at the given position in the array. Until this atomic operation completes,
|
90 | * any other read or write operation against the array will block.
|
91 | */
|
92 | load(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number): number;
|
93 |
|
94 | /**
|
95 | * Stores the bitwise OR of a value with the value at the given position in the array,
|
96 | * returning the original value. Until this atomic operation completes, any other read or write
|
97 | * operation against the array will block.
|
98 | */
|
99 | or(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
100 |
|
101 | /**
|
102 | * Stores a value at the given position in the array, returning the new value. Until this
|
103 | * atomic operation completes, any other read or write operation against the array will block.
|
104 | */
|
105 | store(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
106 |
|
107 | /**
|
108 | * Subtracts a value from the value at the given position in the array, returning the original
|
109 | * value. Until this atomic operation completes, any other read or write operation against the
|
110 | * array will block.
|
111 | */
|
112 | sub(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
113 |
|
114 | /**
|
115 | * If the value at the given position in the array is equal to the provided value, the current
|
116 | * agent is put to sleep causing execution to suspend until the timeout expires (returning
|
117 | * `"timed-out"`) or until the agent is awoken (returning `"ok"`); otherwise, returns
|
118 | * `"not-equal"`.
|
119 | */
|
120 | wait(typedArray: Int32Array, index: number, value: number, timeout?: number): "ok" | "not-equal" | "timed-out";
|
121 |
|
122 | /**
|
123 | * Wakes up sleeping agents that are waiting on the given index of the array, returning the
|
124 | * number of agents that were awoken.
|
125 | * @param typedArray A shared Int32Array.
|
126 | * @param index The position in the typedArray to wake up on.
|
127 | * @param count The number of sleeping agents to notify. Defaults to +Infinity.
|
128 | */
|
129 | notify(typedArray: Int32Array, index: number, count?: number): number;
|
130 |
|
131 | /**
|
132 | * Stores the bitwise XOR of a value with the value at the given position in the array,
|
133 | * returning the original value. Until this atomic operation completes, any other read or write
|
134 | * operation against the array will block.
|
135 | */
|
136 | xor(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
|
137 |
|
138 | readonly [Symbol.toStringTag]: "Atomics";
|
139 | }
|
140 |
|
141 | declare var Atomics: Atomics;
|