From b2add0e46336792020eef287ace0f81211a7df8c Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Wed, 3 Mar 2021 16:21:47 +0100 Subject: [PATCH] Actor atExit and exitHooks --- src/actor.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/actor.ts b/src/actor.ts index 2cc484b..2a4ef53 100644 --- a/src/actor.ts +++ b/src/actor.ts @@ -108,15 +108,15 @@ export class Actor { readonly id = nextActorId++; readonly outbound: Map; exitReason: ExitReason = null; - // readonly exitHooks: Array = []; + readonly exitHooks: Array = []; constructor(initialAssertions = new Map()) { this.outbound = initialAssertions; } - // atExit(a: LocalAction): void { - // this.exitHooks.push(a); - // } + atExit(a: LocalAction): void { + this.exitHooks.push(a); + } terminateWith(t: Turn, reason: Exclude) { if (this.exitReason !== null) return; @@ -124,7 +124,7 @@ export class Actor { if (!this.exitReason.ok) { console.error(`Actor ${this.id} crashed:`, this.exitReason.err); } - // this.exitHooks.forEach(hook => hook(t)); + this.exitHooks.forEach(hook => hook(t)); queueTask(() => t.freshen(t => this.outbound.forEach((peer, h) => t._retract(peer, h))));