2022-08-29 13:49:01 +03:00
|
|
|
// @target: esnext
|
|
|
|
// @lib: es2022
|
|
|
|
// @noemit: true
|
|
|
|
// @strict: true
|
|
|
|
|
|
|
|
const sab = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 1024);
|
|
|
|
const int32 = new Int32Array(sab);
|
2023-02-23 10:55:58 +03:00
|
|
|
const sab64 = new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 1024);
|
|
|
|
const int64 = new BigInt64Array(sab64);
|
2022-08-29 13:49:01 +03:00
|
|
|
const waitValue = Atomics.wait(int32, 0, 0);
|
2023-02-23 10:55:58 +03:00
|
|
|
const { async, value } = Atomics.waitAsync(int32, 0, 0);
|
|
|
|
const { async: async64, value: value64 } = Atomics.waitAsync(int64, 0, BigInt(0));
|
2022-08-29 13:49:01 +03:00
|
|
|
|
|
|
|
const main = async () => {
|
|
|
|
if (async) {
|
|
|
|
await value;
|
|
|
|
}
|
2023-02-23 10:55:58 +03:00
|
|
|
if (async64) {
|
|
|
|
await value64;
|
|
|
|
}
|
2022-08-29 13:49:01 +03:00
|
|
|
}
|
|
|
|
main();
|