Actor atExit and exitHooks
This commit is contained in:
parent
94831bd140
commit
b2add0e463
10
src/actor.ts
10
src/actor.ts
|
@ -108,15 +108,15 @@ export class Actor {
|
|||
readonly id = nextActorId++;
|
||||
readonly outbound: Map<Handle, Ref>;
|
||||
exitReason: ExitReason = null;
|
||||
// readonly exitHooks: Array<LocalAction> = [];
|
||||
readonly exitHooks: Array<LocalAction> = [];
|
||||
|
||||
constructor(initialAssertions = new Map<Handle, Ref>()) {
|
||||
this.outbound = initialAssertions;
|
||||
}
|
||||
|
||||
// atExit(a: LocalAction): void {
|
||||
// this.exitHooks.push(a);
|
||||
// }
|
||||
atExit(a: LocalAction): void {
|
||||
this.exitHooks.push(a);
|
||||
}
|
||||
|
||||
terminateWith(t: Turn, reason: Exclude<ExitReason, null>) {
|
||||
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))));
|
||||
|
|
Loading…
Reference in New Issue