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>
impl<T: Task> Enqueuer<T>
Sourcepub fn add(&self, task: T)
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().
Sourcepub fn extend(&self, tasks: impl IntoIterator<Item = T>)
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> Extend<T> for &Enqueuer<T>
impl<T: Task> Extend<T> for &Enqueuer<T>
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, tasks: I)
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)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)