Atomics.waitAsync: await $262.agent.getReportAsync() in a loop, instead of calling thrice asynchronously. Fixes 2664 (#2676)

This commit is contained in:
Rick Waldron 2020-06-24 16:51:52 -04:00 committed by GitHub
parent a2b45dd33b
commit fcb3b91e4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 17 deletions

View File

@ -11,7 +11,6 @@ features: [Atomics.waitAsync, Atomics, BigInt]
---*/ ---*/
assert.sameValue(typeof Atomics.waitAsync, 'function'); assert.sameValue(typeof Atomics.waitAsync, 'function');
$262.agent.start(` $262.agent.start(`
(async () => { (async () => {
var sab = new SharedArrayBuffer(2048); var sab = new SharedArrayBuffer(2048);
@ -45,11 +44,12 @@ $262.agent.start(`
`); `);
Promise.all([ (async () => {
$262.agent.getReportAsync(), const outcomes = [];
$262.agent.getReportAsync(),
$262.agent.getReportAsync(), for (let i = 0; i < 3; i++) {
]).then(outcomes => { outcomes.push(await $262.agent.getReportAsync());
}
assert.sameValue( assert.sameValue(
outcomes[0], outcomes[0],
@ -67,6 +67,4 @@ Promise.all([
'C not-equal,not-equal,not-equal,not-equal,not-equal', 'C not-equal,not-equal,not-equal,not-equal,not-equal',
'All C values are not equal' 'All C values are not equal'
); );
}).then($DONE, $DONE); })().then($DONE, $DONE);

View File

@ -11,7 +11,6 @@ features: [Atomics.waitAsync, Atomics]
---*/ ---*/
assert.sameValue(typeof Atomics.waitAsync, 'function'); assert.sameValue(typeof Atomics.waitAsync, 'function');
$262.agent.start(` $262.agent.start(`
(async () => { (async () => {
var sab = new SharedArrayBuffer(1024); var sab = new SharedArrayBuffer(1024);
@ -44,11 +43,12 @@ $262.agent.start(`
`); `);
Promise.all([ (async () => {
$262.agent.getReportAsync(), const outcomes = [];
$262.agent.getReportAsync(),
$262.agent.getReportAsync(), for (let i = 0; i < 3; i++) {
]).then(outcomes => { outcomes.push(await $262.agent.getReportAsync());
}
assert.sameValue( assert.sameValue(
outcomes[0], outcomes[0],
@ -66,5 +66,4 @@ Promise.all([
'C not-equal,not-equal,not-equal,not-equal,not-equal', 'C not-equal,not-equal,not-equal,not-equal,not-equal',
'All C values are not equal' 'All C values are not equal'
); );
}).then($DONE, $DONE); })().then($DONE, $DONE);