Struct DispatcherBuilder

Source
pub struct DispatcherBuilder<'a, 'b> { /* private fields */ }
Expand description

Builder for the Dispatcher.

§Barriers

Barriers are a way of sequentializing parts of the system execution. See add_barrier()/with_barrier().

§Examples

This is how you create a dispatcher with a shared thread pool:

let dispatcher: Dispatcher = DispatcherBuilder::new()
    .with(system_a, "a", &[])
    .with(system_b, "b", &["a"]) // b depends on a
    .with(system_c, "c", &["a"]) // c also depends on a
    .with(system_d, "d", &[])
    .with(system_e, "e", &["c", "d"]) // e executes after c and d are finished
    .build();

Systems can be conditionally added by using the add_ functions:

let mut builder = DispatcherBuilder::new()
    .with(system_a, "a", &[]);

if b_enabled {
   builder.add(system_b, "b", &[]);
}

let dispatcher = builder.build();

Implementations§

Source§

impl<'a, 'b> DispatcherBuilder<'a, 'b>

Source

pub 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.

Source

pub fn with<T>( self, system: T, name: &str, dep: &[&str], ) -> DispatcherBuilder<'a, 'b>
where T: for<'c> 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).

Same as add(), but returns self to enable method chaining.

§Panics
  • if the specified dependency does not exist
  • if a system with the same name was already registered.
Source

pub fn add<T>(&mut self, system: T, name: &str, dep: &[&str])
where T: for<'c> 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.
Source

pub fn with_thread_local<T>(self, system: T) -> DispatcherBuilder<'a, 'b>
where T: for<'c> RunNow<'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.

Same as add_thread_local(), but returns self to enable method chaining.

Source

pub fn add_thread_local<T>(&mut self, system: T)
where T: for<'c> RunNow<'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.

Source

pub fn with_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()/with_barrier().

Thread-local systems are not affected by barriers; they’re always executed at the end.

Same as add_barrier(), but returns self to enable method chaining.

Source

pub fn add_barrier(&mut self)

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()/with_barrier().

Thread-local systems are not affected by barriers; they’re always executed at the end.

Source

pub fn print_par_seq(&self)

Prints the equivalent system graph that can be easily used to get the graph using the seq! and par! macros. This is only recommended for advanced users.

Source

pub fn build(self) -> Dispatcher<'a, 'b>

Builds the Dispatcher.

In the future, this method will precompute useful information in order to speed up dispatching.

Trait Implementations§

Source§

impl<'a, 'b> Debug for DispatcherBuilder<'a, 'b>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a, 'b> Default for DispatcherBuilder<'a, 'b>

Source§

fn default() -> DispatcherBuilder<'a, 'b>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a, 'b> Freeze for DispatcherBuilder<'a, 'b>

§

impl<'a, 'b> !RefUnwindSafe for DispatcherBuilder<'a, 'b>

§

impl<'a, 'b> !Send for DispatcherBuilder<'a, 'b>

§

impl<'a, 'b> !Sync for DispatcherBuilder<'a, 'b>

§

impl<'a, 'b> Unpin for DispatcherBuilder<'a, 'b>

§

impl<'a, 'b> !UnwindSafe for DispatcherBuilder<'a, 'b>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> TryDefault for T
where T: Default,

Source§

fn try_default() -> Result<T, String>

Tries to create the default.
Source§

fn unwrap_default() -> Self

Calls try_default and panics on an error case.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Erased for T