Crate shred [−] [src]
Shared resource dispatcher
This library allows to dispatch systems, which can have interdependencies, shared and exclusive resource access, in parallel.
Examples
extern crate shred; #[macro_use] extern crate shred_derive; use shred::{DispatcherBuilder, Fetch, FetchMut, Resource, Resources, System}; #[derive(Debug)] struct ResA; impl Resource for ResA {} #[derive(Debug)] struct ResB; impl Resource for ResB {} #[derive(SystemData)] struct Data<'a> { a: Fetch<'a, ResA>, b: FetchMut<'a, ResB>, } struct EmptySystem; impl<'a, C> System<'a, C> for EmptySystem { type SystemData = Data<'a>; fn work(&mut self, bundle: Data<'a>, _: C) { println!("{:?}", &*bundle.a); println!("{:?}", &*bundle.b); } } fn main() { let mut resources = Resources::new(); let mut dispatcher = DispatcherBuilder::new() .add(EmptySystem, "empty", &[]) .build(); resources.add(ResA, ()); resources.add(ResB, ()); dispatcher.dispatch(&mut resources, ()); }
Structs
AsyncDispatcher |
Like, |
Dispatcher |
The dispatcher struct, allowing systems to be executed in parallel. |
DispatcherBuilder |
Builder for the |
Fetch |
Return value of |
FetchId |
Return value of |
FetchIdMut |
Return value of |
FetchMut |
Return value of |
ResourceId |
The id of a |
Resources |
A resource container, which provides methods to access to the contained resources. |
Traits
Resource |
A resource defines a set of data which can only be accessed according to Rust's typical borrowing model (one writer xor multiple readers). |
System |
A |
SystemData |
A struct implementing system data indicates that it bundles some resources which are required for the execution. |
Functions
run_now |
Runs a system right now. |