[][src]Trait specs::BatchController

pub trait BatchController<'a, 'b> {
    type BatchSystemData: SystemData<'a>;
    unsafe fn create(
        accessor: BatchAccessor,
        dispatcher: Dispatcher<'a, 'b>
    ) -> Self; }

The BatchController is the additional trait that a normal System must implement in order to be used as a system controlling the execution of a batch.

Note that the System must also implement Send because the Dispatcher is by default un-send. The safety of implementing Send is ensured by BatchAccessor which keeps tracks of all used resources and thus the System can be safely executed in with multiple threads.

Associated Types

type BatchSystemData: SystemData<'a>

This associated type has to contain all resources batch controller uses directly.

These have to be specified here, instead of SystemData (as a normal System does) because the sub Systems can use the same Resources of the BatchController. This make necessary to drop the references to the fetched Resources in the batch controller before dispatching the sub Systems.

Now is easy to understand that specify the BatchController Resource in the SystemData doesn't allow to drop the reference before the sub dispatching; resulting in Panic.

So this mechanism allows you to fetch safely the specified Resource in the BatchController. The example "examples/batch_dispatching.rs" show how to use it.

Note that it's not required to specify the sub systems resources here because they are handled automatically.

Loading content...

Required methods

unsafe fn create(
    accessor: BatchAccessor,
    dispatcher: Dispatcher<'a, 'b>
) -> Self

Creates an instance of the BatchControllerSystem.

Usually this function is called internally by the DispatcherBuilder which creates the BatchAccessor correctly. The Dispatcher is constructed by the user elsewhere and passed to the DispatcherBuilder through the functions with_batch or add_batch and passed as argument to this function.


This function is unsafe because an implementor of BatchController is expected to uphold quarantees of Send only when it's created with correctly constructed BatchAccessor. BatchAccessor is meant for tracking which resourced are being used by the controller.

Loading content...


impl<'a, 'b> BatchController<'a, 'b> for DefaultBatchControllerSystem<'a, 'b>[src]

type BatchSystemData = ()

Loading content...