Commit to having onStop shutdownActions run in parent facet context

This commit is contained in:
Tony Garnock-Jones 2021-12-12 23:02:25 +01:00
parent 364c97f357
commit 951598b7d0
1 changed files with 6 additions and 4 deletions

View File

@ -199,7 +199,11 @@ export class Facet {
Turn.active._inFacet(this, () => {
this.children.forEach(child => child._terminate(orderly));
if (orderly) this.shutdownActions.forEach(a => a());
if (orderly) {
Turn.active._inFacet(parent ?? this, () => {
this.shutdownActions.forEach(a => a());
});
}
this.outbound.forEach(e => Turn.active._retract(e));
if (orderly) {
@ -315,9 +319,7 @@ export class Turn {
this.stopActor();
} else {
this.enqueue(facet, () => {
if (continuation) {
facet.onStop(() => Turn.active._inFacet(facetParent, continuation));
}
if (continuation) facet.onStop(continuation);
facet._terminate(true);
});
}