Note that this article applies only to the C++ DSI.
The IDriver interface in the DSI contains the function GetEventHandler(). This function returns a function pointer that allows the SimbaEngine SDK to signal the DSI when different events occur.
The signature of the function is:
Inspecting the definition of DSIEventHandler gives us the following typedef:
typedef void (*DSIEventHandler)(EventID, void*)
There are several EventIDs defined, the two of interest are:
When a new thread is started by the server, the SDK will call the DSIEventHandler function returned by GetEventHandler() with the EVENT_THREAD_START EventID. Likewise, when a thread finishes it will call the DSIEventHandler with the EVENT_THREAD_FINISH EventID. These events will be called immediately after a thread starts and immediately before a thread exits.
Note that the DSIEventHandler will only be called with these two events when your DSII is built as a server, when built as a stand-alone driver the SDK does not control which threads are accessing the DSII.
By default, the DSIDriver implementation of IDriver returns NULL for GetEventHandler() to indicate there is no event handler for the DSII. Simply override the function and provide your own function to receive events from the SDK.