pub struct EventParIter<'a, E: Event> { /* private fields */ }
Expand description
A parallel iterator over Event
s.
Implementations§
Source§impl<'a, E: Event> EventParIter<'a, E>
impl<'a, E: Event> EventParIter<'a, E>
Sourcepub fn new(reader: &'a mut ManualEventReader<E>, events: &'a Events<E>) -> Self
pub fn new(reader: &'a mut ManualEventReader<E>, events: &'a Events<E>) -> Self
Creates a new parallel iterator over events
that have not yet been seen by reader
.
Sourcepub fn batching_strategy(self, strategy: BatchingStrategy) -> Self
pub fn batching_strategy(self, strategy: BatchingStrategy) -> Self
Changes the batching strategy used when iterating.
For more information on how this affects the resultant iteration, see
BatchingStrategy
.
Sourcepub fn for_each<FN: Fn(&'a E) + Send + Sync + Clone>(self, func: FN)
pub fn for_each<FN: Fn(&'a E) + Send + Sync + Clone>(self, func: FN)
Runs the provided closure for each unread event in parallel.
Unlike normal iteration, the event order is not guaranteed in any form.
§Panics
If the ComputeTaskPool
is not initialized. If using this from an event reader that is being
initialized and run from the ECS scheduler, this should never panic.
Sourcepub fn for_each_with_id<FN: Fn(&'a E, EventId<E>) + Send + Sync + Clone>(
self,
func: FN,
)
pub fn for_each_with_id<FN: Fn(&'a E, EventId<E>) + Send + Sync + Clone>( self, func: FN, )
Runs the provided closure for each unread event in parallel, like for_each
,
but additionally provides the EventId
to the closure.
Note that the order of iteration is not guaranteed, but EventId
s are ordered by send order.
§Panics
If the ComputeTaskPool
is not initialized. If using this from an event reader that is being
initialized and run from the ECS scheduler, this should never panic.