Simplify
This commit is contained in:
parent
109441785f
commit
c43ef7e4e7
10
actor.ts
10
actor.ts
|
@ -110,15 +110,13 @@ export class Turn {
|
||||||
}
|
}
|
||||||
|
|
||||||
quit(): void {
|
quit(): void {
|
||||||
const actor = this._ensureActor("quit");
|
this.localActions.push(t => this._ensureActor("quit").terminateWith(t, { ok: true }));
|
||||||
this.localActions.push(t => actor.terminateWith(t, { ok: true }));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(location: Ref<Entity>, assertion: Assertion): Handle {
|
assert(location: Ref<Entity>, assertion: Assertion): Handle {
|
||||||
this._ensureActor("assert");
|
|
||||||
const h = nextHandle++;
|
const h = nextHandle++;
|
||||||
this.enqueue(location.actor, t => {
|
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);
|
location.target[assert]?.(t, assertion, h);
|
||||||
});
|
});
|
||||||
return h;
|
return h;
|
||||||
|
@ -161,9 +159,7 @@ export class Turn {
|
||||||
}
|
}
|
||||||
|
|
||||||
complete(): void {
|
complete(): void {
|
||||||
if (this.completed) {
|
if (this.completed) throw new Error("Reuse of completed Turn!");
|
||||||
throw new Error("Reuse of completed Turn!");
|
|
||||||
}
|
|
||||||
this.completed = true;
|
this.completed = true;
|
||||||
this.queues.forEach((queue, actor) =>
|
this.queues.forEach((queue, actor) =>
|
||||||
actor.execute(() => queue.forEach(f => Turn.for(actor, f))));
|
actor.execute(() => queue.forEach(f => Turn.for(actor, f))));
|
||||||
|
|
Loading…
Reference in New Issue