Expand description
ExecutionEngine — 执行引擎核心类型。
职责分离:
ExecutionEngine<'a, S>— Executor 内部使用,借用 State(&'a mut S), 持有 Mutation 缓冲、流发射器等运行时资源NodeContext<'a, S>/LeafContext<'a, S>— 节点能力视图(在 node_context.rs 中)
§状态所有权模型
ExecutionEngine 借用 State,不拥有它。调用方持有 State 的所有权, Engine 只在执行期间借用。这使得 Subgraph 组合成为可能:
调用方
├── state: S (拥有所有权)
├── engine: Engine<'_, S> (借用 &mut state)
│ └── SubgraphSpec::execute()
│ ├── lens.get(state) → &mut Inner
│ ├── inner_engine: Engine<'_, Inner> (借用 &mut inner)
│ └── graph.run_inline(&mut inner_engine)
└── state 仍然可用(engine drop 后借用释放)数据流单向:
Node
↓
ctx.record(Mutation)
↓
Mutation Buffer (ExecutionEngine)
↓
Engine: take_mutations()
↓
state.apply_batch(mutations)
↓
State节点只能通过 record() 声明变更意图,无法直接修改 State。
这保证了 Mutation Log 是唯一写入口,使 Replay、Trace、Parallel Merge、Undo 全部成立。
Structs§
- Execution
Control - 控制信号容器 — 节点写入,Executor 读取。
- Execution
Engine - 执行引擎 — 借用 State,持有 Mutation 缓冲、流发射器等运行时资源。
- Node
Metadata - 节点元数据 — 提供给 Executor 的额外信息。
- Owned
Execution Engine - 拥有 State 所有权的执行引擎 — 用于 Parallel 分支等需要独立 State 的场景。
Enums§
- Execution
Signal - 控制信号 — 独立枚举,Barrier 挂起不是路由。
- Next
Action - 节点执行后的下一步路由。
Traits§
- Execution
View - 受限视图 — Leaf 节点需要的最小能力。
- Executor
State - 完整能力 — Composite 节点 + LeafAdapter 使用。
Type Aliases§
- Execution
Context - 向后兼容别名 —
ExecutionContext→ExecutionEngine。