Struct pawawwewism::Worker

source ·
pub struct Worker<I: Send + 'static> { /* private fields */ }
Expand description

A handle to a worker thread that processes messages of type I.

This type enforces structured concurrency: When it’s dropped, the thread will be signaled to exit and the thread will be joined. If the thread has panicked, the panic will be forwarded to the thread dropping the Worker.

Implementations§

source§

impl Worker<()>

source

pub fn builder() -> WorkerBuilder

Returns a builder that can be used to configure and spawn a Worker.

source§

impl<I: Send + 'static> Worker<I>

source

pub fn send(&mut self, msg: I)

Sends a message to the worker thread.

If the worker’s channel capacity is exhausted, this will block until the worker is available to accept the message.

If the worker has panicked, this will propagate the panic to the calling thread.

Trait Implementations§

source§

impl<I: Send + 'static> Drop for Worker<I>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<I> !RefUnwindSafe for Worker<I>

§

impl<I> Send for Worker<I>

§

impl<I> Sync for Worker<I>

§

impl<I> Unpin for Worker<I>

§

impl<I> !UnwindSafe for Worker<I>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.