Make actor *stop* an orderly termination (vs crash)

This commit is contained in:
Tony Garnock-Jones 2021-05-31 12:01:50 +02:00
parent 9a06f4a633
commit 2beecfc78e
1 changed files with 3 additions and 3 deletions

View File

@ -60,11 +60,11 @@ export class Actor {
terminateWith(t: Turn, reason: Exclude<ExitReason, null>) {
if (this.exitReason !== null) return;
this.exitReason = reason;
if (!this.exitReason.ok) {
console.error(`Actor ${this.id} crashed:`, this.exitReason.err);
if (!reason.ok) {
console.error(`Actor ${this.id} crashed:`, reason.err);
}
this.exitHooks.forEach(hook => hook(t));
queueTask(() => Turn.for(this.root, t => this.root._terminate(t, false), true));
queueTask(() => Turn.for(this.root, t => this.root._terminate(t, reason.ok), true));
}
}