Skip to content

Commit 9693449

Browse files
Compact compiled statechart runtimes
1 parent 80b3e73 commit 9693449

4 files changed

Lines changed: 526 additions & 3 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@typeonce/effect-machine": patch
3+
---
4+
5+
Run compiled statecharts and their invoked machine children with a single process fiber, reducing lifecycle overhead and idle memory while preserving the general `Machine.logic` runtime contract.

src/internal/machineProcess.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ const makeProcessLogic: <
121121
const hasInvokes = hasInvokeCapability(machine)
122122
return ({
123123
[internalRuntime.childlessProcess]: hasInvokes ? undefined : true,
124+
[internalRuntime.compiledProcess]: true,
124125
initial: (scope) =>
125126
internalRuntime.provideMachineRuntime(
126127
Effect.gen(function*() {
@@ -339,6 +340,9 @@ const makeProcessLogic: <
339340
...(processLogic[internalRuntime.childlessProcess] === true
340341
? { [internalRuntime.childlessProcess]: true as const }
341342
: undefined),
343+
...(processLogic[internalRuntime.compiledProcess] === true
344+
? { [internalRuntime.compiledProcess]: true as const }
345+
: undefined),
342346
initial: (childScope) => logic.initial({ ...childScope, sendParent }),
343347
run: (childContext) => logic.run({ ...childContext, sendParent })
344348
},

0 commit comments

Comments
 (0)