pub struct Spawner { /* private fields */ }
Expand description
The Spawner struct contains the state required to create and cancel jobs
Implementations§
Source§impl Spawner
impl Spawner
Sourcepub fn new(rc: Sender<Event>, listener: Receiver<SpawnerMsg>) -> Self
pub fn new(rc: Sender<Event>, listener: Receiver<SpawnerMsg>) -> Self
Create a new Spawner from the Sender
half of the receiver channel and the Receiver
half
of the Spawner channel
Sourcepub async fn run(&mut self) -> Result<(), Error>
pub async fn run(&mut self) -> Result<(), Error>
Run the spawner
When running, the spawner await
s messages on self.rx
and if the messages are:
SpawnerMsg::Execute
- it will create the cancellation channel for this job and run the executor for this job in a newtask
SpawnerMsg::Cancel
- it will broadcast the cancellation message to the appropriate job so that the job is aborted gracefully
Auto Trait Implementations§
impl Freeze for Spawner
impl !RefUnwindSafe for Spawner
impl Send for Spawner
impl Sync for Spawner
impl Unpin for Spawner
impl !UnwindSafe for Spawner
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