[][src]Struct shred::ParSeq

pub struct ParSeq<P, T> { /* fields omitted */ }

A dispatcher intended to be used with Par and Seq structures.

This is more flexible and performant than Dispatcher, however, you have to check conflicts yourself. That means you cannot run two systems in parallel which write to the same resource; if you'd do that, one of the systems will panic while trying to fetch the SystemData.

Thread-local systems

This dispatcher also allows more freedom for thread-local systems; you can execute wherever you want, just not in parallel with other systems (putting one inside par! will give you a compile-time error saying the Send requirement is unmet).

Examples

#[macro_use(par, seq)]
extern crate shred;


let x = 5u8;

let mut dispatcher = ParSeq::new(
    seq![
        par![
            SysA,
            SysWithLifetime(&x),
            seq![
                SysC,
                SysD,
            ],
        ],
        SysB,
        SysLocal(&x as *const u8),
    ],
    &pool,
);

dispatcher.dispatch(&mut res);

Methods

impl<P, T> ParSeq<P, T> where
    P: Borrow<ThreadPool>,
    T: for<'a> RunWithPool<'a>, 
[src]

pub fn new(run: T, pool: P) -> Self[src]

Creates a new ParSeq dispatcher. run is usually created by using the par! / seq! macros.

pub fn setup(&mut self, res: &mut Resources)[src]

Sets up res for dispatching. This will add default values for required resources by calling System::setup.

pub fn dispatch(&mut self, res: &Resources)[src]

Dispatches the systems using res. This doesn't call any virtual functions.

Please note that this method assumes that no resource is currently borrowed. If that's the case, it panics.

Trait Implementations

impl<'a, P, T> RunNow<'a> for ParSeq<P, T> where
    P: Borrow<ThreadPool>,
    T: for<'b> RunWithPool<'b>, 
[src]

fn dispose(self: Box<Self>, res: &mut Resources)[src]

Performs clean up that requires resources from the Resources. Read more

Auto Trait Implementations

impl<P, T> Send for ParSeq<P, T> where
    P: Send,
    T: Send

impl<P, T> Sync for ParSeq<P, T> where
    P: Sync,
    T: Sync

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: Any
[src]