#events #bevy #concurrency #plugin #frame #reading #concurrently

bin+lib bevy_concurrent_event

A simple concurrent event plugin,the principle is similar to Commads,events can be send/read concurrently, but the reading of events is always in the next bevy frame

1 unstable release

0.1.0 Mar 5, 2024

#2213 in Game dev

MIT license

11KB
134 lines

"A simple concurrent event plugin,the principle is similar to Commads,events can be send/read concurrently, but the reading of events is always in the next bevy frame"

#[derive(Event)] struct E;

fn main() { App::new().add_event_manager::() .... ; } fn send(mut sender:EventsSender){ sender.send(e); ... } fn read(sender:EventsReader){ sender.par_iter()...//iter() }

use bevy::{ app::{App, Update}, ecs::event::Event, }; use bevy_concurrent_event::events::{ ConcurrentEvent, EventsReader, EventsSender, }; use rayon::iter::ParallelIterator;

#[derive(Event)] struct E;

pub fn main() { App::new().add_event_manager::().add_systems( Update, ( |mut s: EventsSender| s.send(E), |r: EventsReader| r.par_read().for_each(|_| {}), ), ); }

Dependencies

~20–48MB
~765K SLoC