Struct shred::DispatcherBuilder
[−]
[src]
pub struct DispatcherBuilder<'c, 't, C = ()> { /* fields omitted */ }
Builder for the Dispatcher
.
Examples
This is how you create a dispatcher with a shared thread pool:
let dispatcher: Dispatcher<()> = DispatcherBuilder::new() .add(system_a, "a", &[]) .add(system_b, "b", &["a"]) // b depends on a .add(system_c, "c", &["a"]) // c also depends on a .add(system_d, "d", &[]) .add(system_e, "e", &["c", "d"]) // e executes after c and d are finished .build();
Methods
impl<'c, 't, C> DispatcherBuilder<'c, 't, C> where
C: 'c,
[src]
C: 'c,
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, system: T, name: &str, dep: &[&str]) -> Self where
T: for<'a> System<'a, C> + Send + 't,
T: for<'a> System<'a, C> + Send + 't,
Adds a new system with a given name and a list of dependencies. Please not that the dependency should be added before you add the depending system.
Panics
- if the specified dependency does not exist
fn add_thread_local<T>(self, system: T) -> Self where
T: for<'a> System<'a, C> + 't,
T: for<'a> System<'a, C> + 't,
Adds a new thread local system.
Please only use this if your struct is
not Send
and Sync
.
Thread-local systems are dispatched in-order.
fn with_pool(self, pool: Arc<ThreadPool>) -> Self
Attach a rayon thread pool to the builder and use that instead of creating one.
fn build(self) -> Dispatcher<'c, 't, C>
Builds the Dispatcher
.
In the future, this method will precompute useful information in order to speed up dispatching.
impl<C> DispatcherBuilder<'static, 'static, C> where
C: 'static,
[src]
C: 'static,
fn build_async(self, res: Resources) -> AsyncDispatcher<C>
Builds an async dispatcher.
It does not allow non-static types and
accepts a Resource
struct.
Trait Implementations
impl<'c, 't, C> Debug for DispatcherBuilder<'c, 't, C>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), FormatError>
Formats the value using the given formatter.