From bea357d51683c728d324479a051728e8fae0859d Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Tue, 23 Feb 2021 11:04:09 +0100 Subject: [PATCH] Tighten --- actor.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/actor.ts b/actor.ts index d1fb527..279fe50 100644 --- a/actor.ts +++ b/actor.ts @@ -70,7 +70,7 @@ type LocalAction = (t: Turn) => void; export class Turn { readonly actor: Actor; readonly queues: Map = new Map(); - readonly localActions: Array = []; + readonly tasks: Array = []; static for(actor: Actor, f: (t: Turn) => void): void { const t = new Turn(actor); @@ -87,14 +87,14 @@ export class Turn { } spawn(bootProc: (t: Turn) => void, initialAssertions = new IdentitySet()): void { - this.localActions.push(() => { + this.tasks.push(() => { const child = new Actor(extractFromMap(this.actor.outbound, initialAssertions)); child.execute(() => Turn.for(child, bootProc)); }); } quit(): void { - this.localActions.push(t => this.actor.terminateWith(t, { ok: true })); + this.tasks.push(t => this.actor.terminateWith(t, { ok: true })); } assert(location: Ref, assertion: Assertion): Handle { @@ -138,9 +138,7 @@ export class Turn { private complete(): void { this.queues.forEach((q, a) => a.execute(() => q.forEach(f => Turn.for(a, f)))); - if (this.localActions.length > 0) { - queueMicrotask(() => this.localActions.forEach(f => Turn.for(this.actor, f))); - } + this.tasks.length && queueMicrotask(() => this.tasks.forEach(f => Turn.for(this.actor, f))); } }