mirror of
https://github.com/nodejs/node.git
synced 2025-05-21 12:25:12 +00:00

PR-URL: https://github.com/nodejs/node/pull/49639 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
31 lines
950 B
JavaScript
31 lines
950 B
JavaScript
// Copyright 2020 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --allow-natives-syntax --expose-gc
|
|
|
|
(function test() {
|
|
const sab = new SharedArrayBuffer(16);
|
|
const i32a = new Int32Array(sab);
|
|
|
|
let resolved = false;
|
|
(function() {
|
|
const result = Atomics.waitAsync(i32a, 0, 0);
|
|
result.value.then(
|
|
(value) => { assertEquals("ok", value); resolved = true; },
|
|
() => { assertUnreachable(); });
|
|
})();
|
|
// Make sure result gets gc()d.
|
|
gc();
|
|
|
|
const notify_return_value = Atomics.notify(i32a, 0, 1);
|
|
assertEquals(1, notify_return_value);
|
|
assertEquals(0, %AtomicsNumWaitersForTesting(i32a, 0));
|
|
assertEquals(1, %AtomicsNumUnresolvedAsyncPromisesForTesting(i32a, 0));
|
|
|
|
setTimeout(()=> {
|
|
assertTrue(resolved);
|
|
assertEquals(0, %AtomicsNumUnresolvedAsyncPromisesForTesting(i32a, 0));
|
|
}, 0);
|
|
})();
|