Closed LaKraven closed 9 years ago
Actually turns out I'd already implemented a solution for this! While it does iterate all the Event Threads in turn, it offsets the negligible performance overhead onto the Dispatching Thread rather than the Processing Thread(s)
The current logic of progression in the Event Engine is analogous to the following:
This approach is somewhat inefficient in that Event References get pushed into the Queues/Stacks of Event Threads not containing a relevant Listener for a majority of Event Types. This means that each Event Thread is iterating through (likely) more (possibly many more) Events than it needs to.
The most efficient approach would be analogous to the following:
Now when the Event Thread comes to process its Queue/Stack of Events, it contains only Events for which it has associated a relevant Listener.
To implement this,
TLKEventListener
will need to register itself into a List contained within a Dictionary keyed on theTLKEventClass
reference dictated by its overriden (implemented)GetEventClass
class function. This occurs when theRegister
procedure is called. Additionally,TLKEventListener
will need to unregister itself from the aforementioned List when itsUnregister
procedure is called.This should considerably improve overall performance on large-scale systems (such as game engines) by targeting only those Event Threads interested in said Event Type.