Struct shred::Dispatcher

source ·
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>

source

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.

source

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.

source

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

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.

source

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.

source

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.

source

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.

source

pub fn try_into_sendable(self) -> Result<SendDispatcher<'a>, Self>

Converts this to a SendDispatcher.

Fails and returns the original distpatcher if it contains thread local systems.

source

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>

source§

fn run_now(&mut self, world: &World)

Runs the system now. Read more
source§

fn setup(&mut self, world: &mut World)

Sets up World for a later call to run_now.
source§

fn dispose(self: Box<Self>, world: &mut World)

Performs clean up that requires resources from the World. This commonly removes components from world which depend on external resources.

Auto Trait Implementations§

§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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>,

§

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.