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 id = nextActorId++;
|
||||||
readonly outbound: Map<Handle, Ref>;
|
readonly outbound: Map<Handle, Ref>;
|
||||||
exitReason: ExitReason = null;
|
exitReason: ExitReason = null;
|
||||||
// readonly exitHooks: Array<LocalAction> = [];
|
readonly exitHooks: Array<LocalAction> = [];
|
||||||
|
|
||||||
constructor(initialAssertions = new Map<Handle, Ref>()) {
|
constructor(initialAssertions = new Map<Handle, Ref>()) {
|
||||||
this.outbound = initialAssertions;
|
this.outbound = initialAssertions;
|
||||||
}
|
}
|
||||||
|
|
||||||
// atExit(a: LocalAction): void {
|
atExit(a: LocalAction): void {
|
||||||
// this.exitHooks.push(a);
|
this.exitHooks.push(a);
|
||||||
// }
|
}
|
||||||
|
|
||||||
terminateWith(t: Turn, reason: Exclude<ExitReason, null>) {
|
terminateWith(t: Turn, reason: Exclude<ExitReason, null>) {
|
||||||
if (this.exitReason !== null) return;
|
if (this.exitReason !== null) return;
|
||||||
|
@ -124,7 +124,7 @@ export class Actor {
|
||||||
if (!this.exitReason.ok) {
|
if (!this.exitReason.ok) {
|
||||||
console.error(`Actor ${this.id} crashed:`, this.exitReason.err);
|
console.error(`Actor ${this.id} crashed:`, this.exitReason.err);
|
||||||
}
|
}
|
||||||
// this.exitHooks.forEach(hook => hook(t));
|
this.exitHooks.forEach(hook => hook(t));
|
||||||
queueTask(() =>
|
queueTask(() =>
|
||||||
t.freshen(t =>
|
t.freshen(t =>
|
||||||
this.outbound.forEach((peer, h) => t._retract(peer, h))));
|
this.outbound.forEach((peer, h) => t._retract(peer, h))));
|
||||||
|
|
Loading…
Reference in New Issue