Skip to content

Commit 1707ea2

Browse files
committed
fix: have timer.tick return a promise that awaits the wake calls
1 parent dbfa393 commit 1707ea2

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

packages/zoe/tools/manualTimer.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ export default function buildManualTimer(log, startValue = 0) {
1919
return deadline;
2020
},
2121
// This function will only be called in testing code to advance the clock.
22-
tick(msg) {
22+
async tick(msg) {
2323
ticks += 1;
2424
log(`@@ tick:${ticks}${msg ? `: ${msg}` : ''} @@`);
2525
if (schedule.has(ticks)) {
26-
for (const h of schedule.get(ticks)) {
26+
await Promise.all(schedule.get(ticks).map(h => {
2727
log(`&& running a task scheduled for ${ticks}. &&`);
28-
E(h).wake(ticks);
29-
}
28+
return E(h).wake(ticks);
29+
}));
3030
}
3131
},
3232
createRepeater(delaySecs, interval) {
@@ -41,14 +41,12 @@ export default function buildManualTimer(log, startValue = 0) {
4141
};
4242
harden(repeater);
4343
const repeaterHandler = {
44-
wake(timestamp) {
44+
async wake(timestamp) {
4545
if (handlers === undefined) {
4646
return;
4747
}
4848
timer.setWakeup(ticks + interval, repeaterHandler);
49-
for (const h of handlers) {
50-
E(h).wake(timestamp);
51-
}
49+
await Promise.all(handlers.map(h => E(h).wake(timestamp)));
5250
},
5351
};
5452
timer.setWakeup(ticks + delaySecs, repeaterHandler);

0 commit comments

Comments
 (0)