Tighten
This commit is contained in:
parent
c8f040f3e4
commit
bea357d516
10
actor.ts
10
actor.ts
|
@ -70,7 +70,7 @@ type LocalAction = (t: Turn) => void;
|
|||
export class Turn {
|
||||
readonly actor: Actor;
|
||||
readonly queues: Map<Actor, LocalAction[]> = new Map();
|
||||
readonly localActions: Array<LocalAction> = [];
|
||||
readonly tasks: Array<LocalAction> = [];
|
||||
|
||||
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<Handle>()): 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<Entity>, 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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue