Struct work_queue::WorkSender
source · pub struct WorkSender<K, C, O> { /* private fields */ }
Expand description
A clonable handle to the work queue. When all clones of WorkSender are dropped, the queue will process all remaining requests and terminate its output stream.
Implementations§
source§impl<K, C, O> WorkSender<K, C, O>where
K: Clone + Eq + Hash,
C: TryMerge,
O: Clone,
impl<K, C, O> WorkSender<K, C, O>where K: Clone + Eq + Hash, C: TryMerge, O: Clone,
sourcepub fn push(
&self,
key: K,
context: C
) -> impl Future<Output = Result<O, Closed>>
pub fn push( &self, key: K, context: C ) -> impl Future<Output = Result<O, Closed>>
Enqueue the given key to be processed by a worker, or attach to an existing request to process this key.
sourcepub fn push_all(
&self,
entries: impl Iterator<Item = (K, C)>
) -> impl Iterator<Item = impl Future<Output = Result<O, Closed>>>
pub fn push_all( &self, entries: impl Iterator<Item = (K, C)> ) -> impl Iterator<Item = impl Future<Output = Result<O, Closed>>>
Enqueue all the given keys to be processed by a worker, merging them with existing known tasks if possible, returning an iterator of the futures that will resolve to the results of processing the keys.
This method is similar to, but more efficient than, mapping an iterator to
WorkSender::push
.