This commit is contained in:
Tony Garnock-Jones 2021-02-22 20:55:49 +01:00
parent 109441785f
commit c43ef7e4e7
1 changed files with 3 additions and 7 deletions

View File

@ -110,15 +110,13 @@ export class Turn {
}
quit(): void {
const actor = this._ensureActor("quit");
this.localActions.push(t => actor.terminateWith(t, { ok: true }));
this.localActions.push(t => this._ensureActor("quit").terminateWith(t, { ok: true }));
}
assert(location: Ref<Entity>, assertion: Assertion): Handle {
this._ensureActor("assert");
const h = nextHandle++;
this.enqueue(location.actor, t => {
this.actor!.outbound.set(h, [location, assertion]);
this._ensureActor("assert").outbound.set(h, [location, assertion]);
location.target[assert]?.(t, assertion, h);
});
return h;
@ -161,9 +159,7 @@ export class Turn {
}
complete(): void {
if (this.completed) {
throw new Error("Reuse of completed Turn!");
}
if (this.completed) throw new Error("Reuse of completed Turn!");
this.completed = true;
this.queues.forEach((queue, actor) =>
actor.execute(() => queue.forEach(f => Turn.for(actor, f))));