Struct shred::DispatcherBuilder
[−]
[src]
pub struct DispatcherBuilder<'t> { /* fields omitted */ }
Builder for the Dispatcher
.
Examples
This is how you create a dispatcher with a shared thread pool:
let dispatcher = DispatcherBuilder::new() .add(task_a, "a", &[]) .add(task_b, "b", &["a"]) // b depends on a .add(task_c, "c", &["a"]) // c also depends on a .add(task_d, "d", &[]) .add(task_e, "e", &["c", "d"]) // e executes after c and d are finished .finish();
Methods
impl<'t> DispatcherBuilder<'t>
[src]
fn new() -> Self
Creates a new DispatcherBuilder
by
using the Default
implementation.
The default behaviour is to create
a thread pool on finish
.
If you already have a rayon ThreadPool
,
it's highly recommended to configure
this builder to use it with with_pool
instead.
fn add<T>(self, task: T, name: &str, dep: &[&str]) -> Self where
T: for<'a> Task<'a> + Send + 't,
T: for<'a> Task<'a> + Send + 't,
Adds a new task with a given name and a list of dependencies. Please not that the dependency should be added before you add the depending task.
Panics
- if the specified dependency does not exist
fn with_pool(self, pool: Arc<ThreadPool>) -> Self
Attach a rayon thread pool to the builder and use that instead of creating one.
fn finish(self) -> Dispatcher<'t>
Builds the Dispatcher
.
In the future, this method will precompute useful information in order to speed up dispatching.
Trait Implementations
impl<'t> Default for DispatcherBuilder<'t>
[src]
fn default() -> DispatcherBuilder<'t>
Returns the "default value" for a type. Read more