Struct async_pipes::WorkerOptions
source · pub struct WorkerOptions {
pub pipe_buffer_size: usize,
pub max_task_count: usize,
}Expand description
Options that can be passed to methods in the PipelineBuilder when defining stages.
This implements Default which makes it easier to specify options when defining stages. By default, each worker will be allowed 100 concurrent tasks maximum and the buffer of each pipe is set to 30.
Examples
use async_pipes::{Pipeline, WorkerOptions};
#[tokio::main]
async fn main() {
let pipeline = Pipeline::builder()
.with_inputs("Pipe", vec![()])
.with_consumer("Pipe", WorkerOptions::default(), |_: ()| async move {
/* ... */
})
.build();
assert!(pipeline.is_ok());
}Fields§
§pipe_buffer_size: usizeThe maximum number of items allowed per pipe before stages have to wait to write more data to the pipe.
max_task_count: usizeThe maximum number of tasks that a worker can be concurrently running. Once this number is reached in a worker, the worker will poll for tasks completions before spawning more.
Implementations§
source§impl WorkerOptions
impl WorkerOptions
sourcepub fn default_single_task() -> Self
pub fn default_single_task() -> Self
Like the Default implementation, but specifies 1 for WorkerOptions::max_task_count.
sourcepub fn default_multi_task() -> Self
pub fn default_multi_task() -> Self
Specifies 100 for WorkerOptions::max_task_count and 30 for
WorkerOptions::pipe_buffer_size.
Trait Implementations§
source§impl Clone for WorkerOptions
impl Clone for WorkerOptions
source§fn clone(&self) -> WorkerOptions
fn clone(&self) -> WorkerOptions
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for WorkerOptions
impl Debug for WorkerOptions
source§impl Default for WorkerOptions
impl Default for WorkerOptions
source§impl Hash for WorkerOptions
impl Hash for WorkerOptions
source§impl Ord for WorkerOptions
impl Ord for WorkerOptions
source§fn cmp(&self, other: &WorkerOptions) -> Ordering
fn cmp(&self, other: &WorkerOptions) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for WorkerOptions
impl PartialEq for WorkerOptions
source§fn eq(&self, other: &WorkerOptions) -> bool
fn eq(&self, other: &WorkerOptions) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl PartialOrd for WorkerOptions
impl PartialOrd for WorkerOptions
source§fn partial_cmp(&self, other: &WorkerOptions) -> Option<Ordering>
fn partial_cmp(&self, other: &WorkerOptions) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Eq for WorkerOptions
impl StructuralEq for WorkerOptions
impl StructuralPartialEq for WorkerOptions
Auto Trait Implementations§
impl RefUnwindSafe for WorkerOptions
impl Send for WorkerOptions
impl Sync for WorkerOptions
impl Unpin for WorkerOptions
impl UnwindSafe for WorkerOptions
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