Dispatches tasks in parallel which need read access to some resources, and write access to others.
```rust extern crate shred;
extern crate shred_derive;
use shred::{DispatcherBuilder, Fetch, FetchMut, Resource, Resources, Task};
struct ResA;
impl Resource for ResA {}
struct ResB;
impl Resource for ResB {}
struct Data<'a> { a: Fetch<'a, ResA>, b: FetchMut<'a, ResB>, }
struct EmptyTask;
impl<'a> Task<'a> for EmptyTask { type TaskData = Data<'a>;
fn work(&mut self, bundle: Data<'a>) {
println!("{:?}", &*bundle.a);
println!("{:?}", &*bundle.b);
}
}
fn main() { let mut resources = Resources::new(); let mut dispatcher = DispatcherBuilder::new() .add(EmptyTask, "empty", &[]) .finish(); resources.add(ResA, ()); resources.add(ResB, ());
dispatcher.dispatch(&mut resources);
} ```
1.15 stable
'static
only)Contribution is highly welcome! If you'd like another feature, just create an issue. You can also help out if you want to; just pick a "help wanted" issue. If you need any help, feel free to ask!
All contributions are assumed to be dual-licensed under MIT/Apache-2.
shred
is distributed under the terms of both the MIT
license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT.