pub struct Dispatcher<'a, 'b> { /* private fields */ }
Expand description
The dispatcher struct, allowing systems to be executed in parallel.
Implementations§
Source§impl<'a, 'b> Dispatcher<'a, 'b>
impl<'a, 'b> Dispatcher<'a, 'b>
Sourcepub fn setup(&mut self, world: &mut World)
pub fn setup(&mut self, world: &mut World)
Sets up all the systems which means they are gonna add default values for the resources they need.
Sourcepub fn dispose(self, world: &mut World)
pub fn dispose(self, world: &mut World)
Calls the dispose
method of all systems and allows them to release
external resources. It is common this method removes components and
/ or resources from the World
which are associated with external
resources.
Sourcepub fn dispatch(&mut self, world: &World)
pub fn dispatch(&mut self, world: &World)
Dispatch all the systems with given resources and context and then run thread local systems.
This function automatically redirects to
- Dispatcher::dispatch_par in case it is supported
- Dispatcher::dispatch_seq otherwise
and runs dispatch_thread_local
afterwards.
Please note that this method assumes that no resource is currently borrowed. If that’s the case, it panics.
Sourcepub fn dispatch_par(&mut self, world: &World)
pub fn dispatch_par(&mut self, world: &World)
Dispatches the systems (except thread local systems) in parallel given the resources to operate on.
This operation blocks the executing thread.
Only available with “parallel” feature enabled.
Please note that this method assumes that no resource is currently borrowed. If that’s the case, it panics.
Sourcepub fn dispatch_seq(&mut self, world: &World)
pub fn dispatch_seq(&mut self, world: &World)
Dispatches the systems (except thread local systems) sequentially.
This is useful if parallel overhead is too big or the platform does not support multithreading.
Please note that this method assumes that no resource is currently borrowed. If that’s the case, it panics.
Sourcepub fn dispatch_thread_local(&mut self, world: &World)
pub fn dispatch_thread_local(&mut self, world: &World)
Dispatch only thread local systems sequentially.
Please note that this method assumes that no resource is currently borrowed. If that’s the case, it panics.
Sourcepub fn max_threads(&self) -> usize
pub fn max_threads(&self) -> usize
This method returns the largest amount of threads this dispatcher can make use of. This is mainly for debugging purposes so you can see how well your systems can make use of multi-threading.
Trait Implementations§
Source§impl<'a, 'b, 'c> RunNow<'a> for Dispatcher<'b, 'c>
impl<'a, 'b, 'c> RunNow<'a> for Dispatcher<'b, 'c>
Auto Trait Implementations§
impl<'a, 'b> Freeze for Dispatcher<'a, 'b>
impl<'a, 'b> !RefUnwindSafe for Dispatcher<'a, 'b>
impl<'a, 'b> !Send for Dispatcher<'a, 'b>
impl<'a, 'b> !Sync for Dispatcher<'a, 'b>
impl<'a, 'b> Unpin for Dispatcher<'a, 'b>
impl<'a, 'b> !UnwindSafe for Dispatcher<'a, 'b>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more