pub struct ChannelRunner { /* private fields */ }Expand description
Execution context for a single Channel.
ChannelRunner provides the runtime environment for parallel
channel execution. Each runner:
- Binds 1:1 with a
Component - Receives Events via an mpsc channel and delivers to Component
- Receives Signals via broadcast and delivers to Component
- Sends World modifications via command queue
- Has read access to the World for queries
- Manages spawned children via ChildSpawner
Implementations§
Source§impl ChannelRunner
impl ChannelRunner
Sourcepub fn hook_registry(&self) -> Option<&SharedHookRegistry>
pub fn hook_registry(&self) -> Option<&SharedHookRegistry>
Returns a reference to the shared hook registry, if configured.
Sourcepub fn create_child_context(
&self,
child_id: &str,
) -> Option<Box<dyn ChildContext>>
pub fn create_child_context( &self, child_id: &str, ) -> Option<Box<dyn ChildContext>>
Creates a ChildContext for use by managed children.
The returned context can be injected into LuaChild instances to enable them to spawn sub-children.
Returns None if child spawning was not enabled for this runner.
Sourcepub fn create_child_context_with_loader(
&self,
child_id: &str,
loader: Arc<dyn LuaChildLoader>,
) -> Option<Box<dyn ChildContext>>
pub fn create_child_context_with_loader( &self, child_id: &str, loader: Arc<dyn LuaChildLoader>, ) -> Option<Box<dyn ChildContext>>
Creates a ChildContext with a LuaChildLoader for spawning Lua children.
§Arguments
child_id- ID of the child that will use this contextloader- Loader for creating LuaChild instances from configs
Sourcepub fn create_async_child_context(
&self,
child_id: &str,
) -> Option<Box<dyn AsyncChildContext>>
pub fn create_async_child_context( &self, child_id: &str, ) -> Option<Box<dyn AsyncChildContext>>
Creates an AsyncChildContext for use by async children.
The returned context can be used with async spawn operations.
Returns None if child spawning was not enabled for this runner.
Sourcepub fn create_async_child_context_with_loader(
&self,
child_id: &str,
loader: Arc<dyn LuaChildLoader>,
) -> Option<Box<dyn AsyncChildContext>>
pub fn create_async_child_context_with_loader( &self, child_id: &str, loader: Arc<dyn LuaChildLoader>, ) -> Option<Box<dyn AsyncChildContext>>
Creates an AsyncChildContext with a LuaChildLoader.
§Arguments
child_id- ID of the child that will use this contextloader- Loader for creating LuaChild instances from configs
Sourcepub fn child_spawner(&self) -> Option<&Arc<StdMutex<ChildSpawner>>>
pub fn child_spawner(&self) -> Option<&Arc<StdMutex<ChildSpawner>>>
Returns a reference to the child spawner, if enabled.
Sourcepub fn world_tx(&self) -> &Sender<WorldCommand>
pub fn world_tx(&self) -> &Sender<WorldCommand>
Returns a reference to the world_tx sender.
Sourcepub async fn run(self) -> RunnerResult
pub async fn run(self) -> RunnerResult
Runs the channel’s event loop.
This method consumes the runner and processes events until:
- The channel is completed or killed
- A Veto signal is received
- All event senders are dropped
After the event loop exits, executes the shutdown sequence:
- Capture component snapshot (if supported)
- Call
component.shutdown()for cleanup - Return
RunnerResultwith snapshot
If an initial snapshot was provided via
ChannelRunnerBuilder::with_initial_snapshot(), it is restored
before init() is called.
Sourcepub async fn spawn_child(
&self,
config: ChannelConfig,
signal_rx: Receiver<Signal>,
component: Box<dyn Component>,
) -> Option<(ChannelRunner, ChannelHandle)>
pub async fn spawn_child( &self, config: ChannelConfig, signal_rx: Receiver<Signal>, component: Box<dyn Component>, ) -> Option<(ChannelRunner, ChannelHandle)>
Spawns a child channel with a bound Component.
Returns the new channel’s ID and handle, or None if spawn failed.