bevy_pareventwriter

Crates.iobevy_pareventwriter
lib.rsbevy_pareventwriter
version0.1.0
created_at2025-09-30 03:33:43.477082+00
updated_at2025-09-30 03:33:43.477082+00
descriptionA simple library for Bevy to write events in parallel.
homepage
repositoryhttps://github.com/Totobird-Creations/bevy_pareventwriter
max_upload_size
id1860530
size24,069
Totobird (Totobird-Creations)

documentation

README

bevy_pareventwriter

A simple library for Bevy to write events in parallel.

Why?

Bevy has the EventWriter<T> system parameter. However, if you are parallel iterating through something such as a query (Query::par_iter), EventWriters are unusable.

ParallelEventWriter keeps thread-local event queues, which are merged and sent after the system finishes.

Example

Here is a crude example of where this might be useful.

fn parallel_event_system(
    mut query : Query<(Entity, &Velocity)>,
    par_writer : ParallelEventWriter<Supersonic>
) {
    query.par_iter().for_each(|(entity, velocity)| {
        if velocity.magnitude() > 343.2 {
            par_writer.write(Supersonic { entity });
        }
    });
}

ParallelEventWriter can be used to write events from inside of the parallel iteration.

Commit count: 0

cargo fmt