pub struct ChildSpawner { /* private fields */ }Expand description
Spawner for managing children within a Runner.
Implementations§
Source§impl ChildSpawner
impl ChildSpawner
Sourcepub fn new(parent_id: impl Into<String>, output_tx: OutputSender) -> Self
pub fn new(parent_id: impl Into<String>, output_tx: OutputSender) -> Self
Creates a new ChildSpawner.
§Arguments
parent_id- ID of the parent Component/Childoutput_tx- Sender for output events
Sourcepub fn with_max_children(self, max: usize) -> Self
pub fn with_max_children(self, max: usize) -> Self
Sets the maximum number of children.
Sourcepub fn child_count(&self) -> usize
pub fn child_count(&self) -> usize
Returns the number of active children.
Sourcepub fn max_children(&self) -> usize
pub fn max_children(&self) -> usize
Returns the maximum allowed children.
Sourcepub fn spawn(
&mut self,
config: ChildConfig,
child: Box<dyn RunnableChild>,
) -> Result<Box<dyn ChildHandle>, SpawnError>
pub fn spawn( &mut self, config: ChildConfig, child: Box<dyn RunnableChild>, ) -> Result<Box<dyn ChildHandle>, SpawnError>
Sourcepub fn spawn_async(
&mut self,
config: ChildConfig,
child: Box<dyn RunnableChild>,
) -> Result<Box<dyn AsyncChildHandle>, SpawnError>
pub fn spawn_async( &mut self, config: ChildConfig, child: Box<dyn RunnableChild>, ) -> Result<Box<dyn AsyncChildHandle>, SpawnError>
Spawns a child and returns an async handle.
Unlike Self::spawn(), this returns a handle that properly uses
spawn_blocking for async execution.
§Arguments
config- Configuration for the childchild- The RunnableChild instance
§Errors
Returns error if:
- Max children reached
- Child with same ID already exists
Sourcepub fn propagate_signal(&mut self, signal: &Signal)
pub fn propagate_signal(&mut self, signal: &Signal)
Propagates a signal to all children.
Sourcepub fn reap_finished(&mut self) -> Vec<(String, Status)>
pub fn reap_finished(&mut self) -> Vec<(String, Status)>
Removes finished children and returns their results.
Sourcepub fn output_tx(&self) -> &OutputSender
pub fn output_tx(&self) -> &OutputSender
Returns the output sender.
Sourcepub fn get_child_arc(
&self,
id: &str,
) -> Option<Arc<Mutex<Box<dyn RunnableChild>>>>
pub fn get_child_arc( &self, id: &str, ) -> Option<Arc<Mutex<Box<dyn RunnableChild>>>>
Returns a clone of the child’s Arc for out-of-lock execution.
Used by send_to_children_batch to collect child references while
briefly holding the spawner lock, then release it before running.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ChildSpawner
impl RefUnwindSafe for ChildSpawner
impl Send for ChildSpawner
impl Sync for ChildSpawner
impl Unpin for ChildSpawner
impl UnsafeUnpin for ChildSpawner
impl UnwindSafe for ChildSpawner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more