Don't run external turns when space is paused

This commit is contained in:
Tony Garnock-Jones 2023-12-21 14:13:45 +13:00
parent 4e1475a176
commit e2e72467cd
3 changed files with 12 additions and 0 deletions

View File

@ -304,6 +304,13 @@ export class Turn {
if (facet.actor.exitReason !== null) return;
if (!facet.isLive) return;
}
if (!facet.actor.space.isRunning()) {
facet.actor.space.queueTask({
perform() { Turn.for(facet, f, zombieTurn); },
describe() { return { type: 'externalTurn' } },
});
return;
}
const t = new Turn(facet);
try {
const saved = Turn.active;

View File

@ -55,6 +55,10 @@ export class ActorSpace {
this.inboundAssertions.delete(handle);
}
isRunning() {
return this.state === ActorSpaceState.RUNNING;
}
shutdown(reason: Exclude<ExitReason, null>) {
if (this.state === ActorSpaceState.TERMINATED) return;
this.state = ActorSpaceState.TERMINATED;

View File

@ -15,6 +15,7 @@ export interface StructuredTask<T> {
export type TaskDescription =
| { type: 'bootActor', detail: q.OptionalAny }
| { type: 'turn', tasks: TaskAction[] }
| { type: 'externalTurn' }
;
export type TaskAction = { targetFacet: Facet, action: ActionDescription };