Skip to main content

Enqueuer

Struct Enqueuer 

Source
pub struct Enqueuer<T: Task> { /* private fields */ }
Expand description

A handle to enqueue tasks for a Worker.

Worker::enqueue() / enqueue_one() is the most convenient way to enqueue new tasks, but can be troublesome if the Worker is not directly available or borrowed elsewhere. An Enqueuer is a dedicated handle to the Worker for enqueueing new tasks, and can help work around such issues. Most notably, it can be used while the worker is asleep. It can be accessed via Worker::enqueuer() (which returns &Rc<Enqueuer<T>>).

Implementations§

Source§

impl<T: Task> Enqueuer<T>

Source

pub fn add(&self, task: T)

Enqueue a task.

If the worker is asleep, it will be woken up.

§Panics

Panics if this is called while the enqueuer is borrowed, e.g. it is within a call to Enqueuer::extend().

Source

pub fn extend(&self, tasks: impl IntoIterator<Item = T>)

Enqueue a set of tasks.

If the worker is asleep, it will be woken up.

§Panics

Panics if this is called while the enqueuer is borrowed, e.g. it is within a(nother) call to Enqueuer::extend().

Trait Implementations§

Source§

impl<T: Task> Drop for Enqueuer<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<T: Task> Extend<T> for &Enqueuer<T>

Source§

fn extend<I: IntoIterator<Item = T>>(&mut self, tasks: I)

Enqueue a set of tasks.

This is equivalent to (and is defined as) Enqueuer::extend().

If the worker is asleep, it will be woken up.

§Panics

Panics if this is called while the enqueuer is borrowed, e.g. it is within a(nother) call to Enqueuer::extend().

Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for Enqueuer<T>

§

impl<T> !RefUnwindSafe for Enqueuer<T>

§

impl<T> !Send for Enqueuer<T>

§

impl<T> !Sync for Enqueuer<T>

§

impl<T> Unpin for Enqueuer<T>

§

impl<T> UnsafeUnpin for Enqueuer<T>

§

impl<T> UnwindSafe for Enqueuer<T>
where T: RefUnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.