Is there a way to pass Events between Systems in a multi-threaded Entity-Component-System that realizes the benefits of saving on system resources?
I've read a german article about the Entity-Component-System design-pattern. In this article, the author wrote, that it would be good to let the systems communicate via Events with each other. So, if the CollisionSystem fires an CollisionEvent when an Entity has collided with another one the SoundSystem can play a sound.
I've implemented that with the Observer-pattern: An EventManager receives events from Systems and notifies all Systems. Then the Systems can look themselves if the want to react on that Event.
By using this Event-based system I can save a lot of computer-power. A System just does anything if it has to do. The author from the article also wrote, that because of that encapsulation from Systems you can put every System in it's own thread.
I tried to implement that behavior, but noticed, that if System A fires an Event and System B reacts on this Event because it's update-Method is called from the EventManager, the action gets called in the Thread of System A.
The only solution which comes to my mind is, to have a loop inside each System which looks in a fixed frequency through a Event-Queue and if it finds an interesting Event it fires the action by itself. In that way I would loose my Observer-Pattern and would not save the computer-power.