Experiment: run facet teardown in the current turn, immediately, instead of delayed
This commit is contained in:
parent
8f2d598201
commit
ed8adae3f2
|
@ -117,14 +117,14 @@ export class Actor {
|
|||
this.exitHooks.push(a);
|
||||
}
|
||||
|
||||
terminateWith(reason: Exclude<ExitReason, null>) {
|
||||
_terminateWith(reason: Exclude<ExitReason, null>) {
|
||||
if (this.exitReason !== null) return;
|
||||
this.exitReason = reason;
|
||||
if (!reason.ok) {
|
||||
console.error(`${this} crashed:`, reason.err);
|
||||
}
|
||||
this.exitHooks.forEach(hook => hook());
|
||||
queueTask(() => Turn.for(this.root, () => this.root._terminate(reason.ok), true));
|
||||
this.root._terminate(reason.ok);
|
||||
}
|
||||
|
||||
repairDataflowGraph() {
|
||||
|
@ -207,15 +207,13 @@ export class Facet {
|
|||
this.outbound.forEach(e => Turn.active._retract(e));
|
||||
|
||||
if (orderly) {
|
||||
queueTask(() => {
|
||||
if (parent) {
|
||||
if (parent.isInert()) {
|
||||
Turn.for(parent, () => parent._terminate(true));
|
||||
}
|
||||
} else {
|
||||
Turn.for(this.actor.root, () => this.actor.terminateWith({ ok: true }), true);
|
||||
if (parent) {
|
||||
if (parent.isInert()) {
|
||||
parent._terminate(true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.actor._terminateWith({ ok: true });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -278,7 +276,7 @@ export class Turn {
|
|||
}
|
||||
t.deliver();
|
||||
} catch (err) {
|
||||
Turn.for(facet.actor.root, () => facet.actor.terminateWith({ ok: false, err }));
|
||||
Turn.for(facet.actor.root, () => facet.actor._terminateWith({ ok: false, err }));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,14 +312,11 @@ export class Turn {
|
|||
}
|
||||
|
||||
stop(facet: Facet = this.activeFacet, continuation?: LocalAction) {
|
||||
const facetParent = facet.parent;
|
||||
if (facetParent === null) {
|
||||
if (facet.parent === null) {
|
||||
this.stopActor();
|
||||
} else {
|
||||
this.enqueue(facet, () => {
|
||||
if (continuation) facet.onStop(continuation);
|
||||
facet._terminate(true);
|
||||
});
|
||||
if (continuation) facet.onStop(continuation);
|
||||
facet._terminate(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -361,11 +356,11 @@ export class Turn {
|
|||
}
|
||||
|
||||
stopActor(): void {
|
||||
this.enqueue(this.activeFacet.actor.root, () => this.activeFacet.actor.terminateWith({ ok: true }));
|
||||
this.enqueue(this.activeFacet.actor.root, () => this.activeFacet.actor._terminateWith({ ok: true }));
|
||||
}
|
||||
|
||||
crash(err: Error): void {
|
||||
this.enqueue(this.activeFacet.actor.root, () => this.activeFacet.actor.terminateWith({ ok: false, err }));
|
||||
this.enqueue(this.activeFacet.actor.root, () => this.activeFacet.actor._terminateWith({ ok: false, err }));
|
||||
}
|
||||
|
||||
field<V extends Value<T>, T = Ref>(initial: V, name?: string): Field<V, T> {
|
||||
|
|
Loading…
Reference in New Issue