(searched forum and google, but nothing answers my questions)
Hey guys,
I am currently starting to prepare writing a game engine ( early stage, yes... )
Anyway, I got myself Game Programming Patterns by Robert Nystrom and Game Engine Architecture second edition by Jason Gregory. (and some C++ skills of course)
In Game Programming Patterns I encountered the observer pattern. The book states that the observer pattern is much faster than an event driven pattern using a queue.
In the observer pattern you register the observers at the subject in order to get notified.
Here my first question:
What exactly is the subject ? As far as I understood it is not the observed engine subsystem but more like a specific event inside the subsystem.
Second question:
When I got the previous right, what is such an engine event ? Is it a specific function that gets called like physicsFalling() ? Or what is it ?
So when you have to register your observers at the subject this is to me pretty much the same like a message queue, just that you reduce the amount of listeners. But why is the observer pattern faster than the events or messaging ? When an event is broadcasted over every subsystem there is in my eyes only a small check whether or not this event should be handled. So this can't be the reason for the perfomance difference. Maybe this check is more performance heavy than I think ?
Third question:
Why is observer significantly faster than events/messaging as stated by Chris Nystrom in Game Programming Patterns ?
Greetings
MAPster7