-
Hello, I'm looking to use the entt signal system for my Sim -> UI communication. My sim and UI currently run on the same thread, but I'm thinking a bit towards future-proofing by making sure my data flow can be made thread-safe. My first thought on how this should be connected is that the registry (and other sim classes with signals) would be passed to my UI so it can connect to the desired signals. Then, the sim would run at some point and emit signals as appropriate. To make it thread-safe however, the signals would have to be queued. Then, they could be safely dispatched by the UI thread when it comes around. Is there a way to do this with entt signals? Reading the docs it seems like that might be where collectors come in, but I'm having some trouble seeing how it all comes together. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Out of the box, signal support for storage classes isn't thread safe. It fits the way one should use an ECS, that is, by elaborating different component types in parallel. |
Beta Was this translation helpful? Give feedback.
Out of the box, signal support for storage classes isn't thread safe. It fits the way one should use an ECS, that is, by elaborating different component types in parallel.
However, signal support is just a mixin. If you do want to make it fully thread safe, you can by switching it off and replacing it with your own implementation.
That being said, I would probably spawn signals as components in my simulation, then have a system at the end of the loop that forwards all these items to their listeners. This way, you don't have to reinvent the wheel or add yet another layer on top of something that works already for what you're looking for.
Dunno if it's clear, let me know in case it is not a…