#Alternative to EventReader/Writer?
1 messages · Page 1 of 1 (latest)
problem is they can't be trusted when systems are running in different threads. How do people handle this problem in general?
They can be trusted though? Are you ordering your systems?
I have a system that runs the ui (egui) it runs at an unspecifed fps, then another running the gamelogic at 60fps..the 60fps doesnt receive the messages always from the gui
Oh right
That's because events are double-buffered
Not a problem with threads
But the events aren't persisting long enough
You could replace the cleanup logic added via .add_event with your own equivalent
Since there are so many ways to to schedule your systems, will the event system ever be truly useful?
"You could replace the cleanup logic added via .add_event with your own equivalent"
Not sure what you mean here
https://github.com/bevyengine/rfcs/pull/32 This discusses an alternative architecture
Yes ok..but nothing concrete now? I'd say the event buffer (or whatever it is) should simply be cleared wh all systems ran..though that probably causes other problems
So, you can see how events work right now
They're just stored in a resource
And you have a cleanup system that runs every frame
But that doesn't work if you need events from older than two frames ago
Which can happen when you're using a fixed timestep
Instead, you could make your own system
And an extension method on App
Which runs the cleanup logic after every fixed timestep has elapsed
Which will avoid this issue
extension method on app? what is that?
To add more methods to foreign types
OK thought that wasnt possible..I tried that but got errors
Pretty neat
This page describes the problem it seems https://bevy-cheatbook.github.io/patterns/manual-event-clear.html
Yes 🙂
Proper writeup for you: https://github.com/bevyengine/bevy/issues/7691
Thanks
I dont see alternatives to fixed time step, since the game runs at 300fps on my laptop screen, and 60 on my stationary screen. Cant have game run differently depending on screen
I would consider using bevy_framepace for now
Ah ok that makes it possible just to run everything like a completely barebones bevy app..thanks for the tip! should take care of the event problem as well.
Yep! It's a lovely crate
an alternative is to use a channel https://docs.rs/crossbeam-channel/latest/crossbeam_channel/ you can just store it in a Resource
Multi-producer multi-consumer channels for message passing.