pub struct WorkerHandle { /* private fields */ }Expand description
Handle to a worker registered on a SharedRuntime.
This handle can be used to stop the worker.
§Warning
If every clone of this handle is dropped without calling WorkerHandle::stop, the worker
remains registered on the SharedRuntime and can only be torn down by shutting the
runtime down. Workers are expected to detect that their input channel has been closed and
park themselves to avoid spinning, but they will not be freed until the runtime stops.
Implementations§
Source§impl WorkerHandle
impl WorkerHandle
Sourcepub async fn stop(self) -> Result<(), WorkerHandleError>
pub async fn stop(self) -> Result<(), WorkerHandleError>
Stop the worker and execute the shutdown logic.
§Errors
Returns an error if the worker has already been stopped.
§Cancel safety
This function is NOT cancel safe and shouldn’t be called in Worker::trigger. If cancelled, the stopped worker can end up in an invalid state if a fork occurs while stopping.
Trait Implementations§
Source§impl Clone for WorkerHandle
impl Clone for WorkerHandle
Source§fn clone(&self) -> WorkerHandle
fn clone(&self) -> WorkerHandle
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WorkerHandle
impl RefUnwindSafe for WorkerHandle
impl Send for WorkerHandle
impl Sync for WorkerHandle
impl Unpin for WorkerHandle
impl UnsafeUnpin for WorkerHandle
impl UnwindSafe for WorkerHandle
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