Skip to main content

ExecutionShell

Struct ExecutionShell 

Source
pub struct ExecutionShell { /* private fields */ }
Expand description

sans-IO 确定性执行壳。

§使用方式(三端通用)

ⓘ
let mut shell = ExecutionShell::new();
shell.register(ImModule::new(config));
shell.start()?;

// 事件泵(由 driver 的 engine_loop.rs 驱动)
let effects = shell.step(Tick::Inbound(bytes), now_ms)?;
// driver 兑现 effects,把结果包成下一个 Tick 喂回

Implementations§

Source§

impl ExecutionShell

Source

pub fn new() -> Self

Source

pub fn register(&mut self, m: impl Module + 'static)

注册业务模块(加模块不改此函数,开闭原则)

Source

pub fn start(&mut self) -> Result<&[Effect], CoreError>

启动所有已注册模块(调用 on_start),返回初始 Effect 列表。

driver 在创建完 ExecutionShell 并注册所有模块后调用一次。

§BLK-1a 修复

逐模块调用 on_start 并立即 register_effects_to_maps(idx), 确保每个模块的 Correlation/TimerId 注册到正确的 module_index。

Source

pub fn stop(&mut self) -> Result<&[Effect], CoreError>

停止所有已注册模块(调用 on_stop),返回清理 Effect 列表。

Source

pub fn step(&mut self, tick: Tick, now_ms: u64) -> Result<&[Effect], CoreError>

核心方法:处理一个 Tick,返回本次 step 产出的 Effect 切片。

§返回值生命周期

返回 &[Effect] 借用 self.scratch,在下一次 step() 调用前有效。 driver 必须在下一次 step() 之前消费完(或 clone)这些 Effect。

§路由策略
  • Inbound / Command:线性扫描 accepts()
  • PortReply:corr_map O(1) 定向投递并消费
  • PortProgress:corr_map O(1) 定向投递但不消费
  • Timer:timer_map O(1) 定向投递
§BLK-1a 修复

dispatch_inbound 返回的 Some(idx) 现在被正确传入 register_effects_to_maps, 替换了原来的 let module_index = 0usize; // placeholder 占位符。 这确保多模块场景中,Correlation/TimerId 被注册到正确的 module_index, 而不是错误地路由到 module[0]。

Trait Implementations§

Source§

impl Default for ExecutionShell

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more