Skip to main content

Module execution_engine

Module execution_engine 

Source
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§

ExecutionControl
控制信号容器 — 节点写入,Executor 读取。
ExecutionEngine
执行引擎 — 借用 State,持有 Mutation 缓冲、流发射器等运行时资源。
NodeMetadata
节点元数据 — 提供给 Executor 的额外信息。
OwnedExecutionEngine
拥有 State 所有权的执行引擎 — 用于 Parallel 分支等需要独立 State 的场景。

Enums§

ExecutionSignal
控制信号 — 独立枚举,Barrier 挂起不是路由。
NextAction
节点执行后的下一步路由。

Traits§

ExecutionView
受限视图 — Leaf 节点需要的最小能力。
ExecutorState
完整能力 — Composite 节点 + LeafAdapter 使用。

Type Aliases§

ExecutionContext
向后兼容别名 — ExecutionContextExecutionEngine