静态
Atomics
.notify()
method notifies up some agents that are sleeping in the wait queue.
注意:
This operation works with a shared
Int32Array
only.
It will return
0
on non-shared
ArrayBuffer
对象。
Atomics.notify(typedArray, index, count)
typedArray
Int32Array
.
index
typedArray
to wake up on.
count
可选
+Infinity
.
0
, if a non-shared
ArrayBuffer
object is used.
TypeError
, if
typedArray
is not a
Int32Array
.
RangeError
, if
index
is out of bounds in the
typedArray
.
notify
Given a shared
Int32Array
:
const sab = new SharedArrayBuffer(1024); const int32 = new Int32Array(sab);
A reading thread is sleeping and waiting on location 0 which is expected to be 0. As long as that is true, it will not go on. However, once the writing thread has stored a new value, it will be notified by the writing thread and return the new value (123).
Atomics.wait(int32, 0, 0); console.log(int32[0]); // 123
A writing thread stores a new value and notifies the waiting thread once it has written:
console.log(int32[0]); // 0; Atomics.store(int32, 0, 123); Atomics.notify(int32, 0, 1);
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'Atomics.notify' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
notify
|
Chrome
68
|
Edge 79 |
Firefox
78
|
IE No | Opera No |
Safari
10.1 — 11.1
Alternate Name
|
WebView Android
60 — 63
Alternate Name
|
Chrome Android
60 — 63
Alternate Name
|
Firefox Android
63
Disabled
|
Opera Android No | Safari iOS 10.3 — 11.3 |
Samsung Internet Android
No
Alternate Name
|
nodejs
8.10.0
Alternate Name
|
完整支持
不支持
见实现注意事项。
用户必须明确启用此特征。
使用非标名称。
Atomics
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()