Struct specs::DispatcherBuilder
[−]
[src]
pub struct DispatcherBuilder<'a, 'b> { /* fields omitted */ }
Builder for the Dispatcher
.
Barriers
Barriers are a way of sequentializing parts of
the system execution. See add_barrier()
.
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<'a, 'b> DispatcherBuilder<'a, 'b>
[src]
fn new() -> DispatcherBuilder<'a, 'b>
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]
) -> DispatcherBuilder<'a, 'b> where
T: System<'c> + Send + 'a,
self,
system: T,
name: &str,
dep: &[&str]
) -> DispatcherBuilder<'a, 'b> where
T: System<'c> + Send + 'a,
Adds a new system with a given name and a list of dependencies. Please note that the dependency should be added before you add the depending system.
If you want to register systems which can not be specified as
dependencies, you can use ""
as their name, which will not panic
(using another name twice will).
Panics
- if the specified dependency does not exist
- if a system with the same name was already registered.
fn add_thread_local<T>(self, system: T) -> DispatcherBuilder<'a, 'b> where
T: System<'c> + 'b,
T: System<'c> + 'b,
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 add_barrier(self) -> DispatcherBuilder<'a, 'b>
Inserts a barrier which assures that all systems added before the barrier are executed before the ones after this barrier.
Does nothing if there were no systems added
since the last call to add_barrier()
.
Thread-local systems are not affected by barriers; they're always executed at the end.
fn with_pool(self, pool: Arc<ThreadPool>) -> DispatcherBuilder<'a, 'b>
Attach a rayon thread pool to the builder and use that instead of creating one.
fn build(self) -> Dispatcher<'a, 'b>
Builds the Dispatcher
.
In the future, this method will precompute useful information in order to speed up dispatching.
impl<'b> DispatcherBuilder<'static, 'b>
[src]
fn build_async(self, res: Resources) -> AsyncDispatcher<'b>
Builds an async dispatcher.
It does not allow non-static types and
accepts a Resource
struct.
Trait Implementations
impl<'a, 'b> Default for DispatcherBuilder<'a, 'b>
[src]
fn default() -> DispatcherBuilder<'a, 'b>
Returns the "default value" for a type. Read more