pub struct TaskSpawner { /* private fields */ }Expand description
Spawns and manages the lifecycle of a task
Implementations§
Source§impl TaskSpawner
impl TaskSpawner
Source§impl TaskSpawner
impl TaskSpawner
Sourcepub fn new(task_name: String, config: TaskConfig) -> Self
pub fn new(task_name: String, config: TaskConfig) -> Self
Create a new task spawner for the given task name and configuration
Sourcepub fn set_stdin(self, stdin_rx: Receiver<String>) -> Self
pub fn set_stdin(self, stdin_rx: Receiver<String>) -> Self
Set the stdin receiver for the task, enabling asynchronous input
Has no effect if enable_stdin is false in the configuration
Sourcepub async fn is_running(&self) -> bool
pub async fn is_running(&self) -> bool
Check if the task is currently running
Sourcepub async fn get_task_info(&self) -> TaskInfo
pub async fn get_task_info(&self) -> TaskInfo
Get information about the task, including name, state, and uptime
Sourcepub async fn send_terminate_signal(
&self,
reason: TaskTerminateReason,
) -> Result<(), TaskError>
pub async fn send_terminate_signal( &self, reason: TaskTerminateReason, ) -> Result<(), TaskError>
Send a termination signal to the running task
Returns an error if the signal cannot be sent
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TaskSpawner
impl !RefUnwindSafe for TaskSpawner
impl Send for TaskSpawner
impl Sync for TaskSpawner
impl Unpin for TaskSpawner
impl !UnwindSafe for TaskSpawner
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