#Alternative to EventReader/Writer?

1 messages · Page 1 of 1 (latest)

remote knot
#

For inter-system communication there seems to be only EventReader/Writer..problem is they can't be trusted when systems are running in different threads. How do people handle this problem in general?

outer sphinx
#

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?

remote knot
outer sphinx
#

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

remote knot
#

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

outer sphinx
remote knot
#

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

outer sphinx
#

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

remote knot
#

extension method on app? what is that?

remote knot
#

OK thought that wasnt possible..I tried that but got errors

#

Pretty neat

outer sphinx
#

Yes 🙂

remote knot
#

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

outer sphinx
remote knot
#

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.

outer sphinx
#

Yep! It's a lovely crate

foggy wolf