etl
etl copied to clipboard
Feature request: deferred timers
Current situation: The existent timers do not allow changes on timer (i.e: call timer functions, due design and mutex protection) while handling the expired callbacks, on tick(). Also it is expected to be real-time (callbacks handlers should run as fast as possible) as the timeout callback will be called inside the tick update, so other timers will not suffer from delays.
Feature request: to implement a timer that create a queue of delegates on the tick update and a method to allow later pop from that queue. Bonus: Implement another version with priority_queue
Pseudo code:
On_Tick() {
bool anyTimeExpired = timer.tick( elapsed_time_ms );
if (anyTimeExpired) {
OS_Notify_DeferedWorker_Task();
}
}
DeferedWorker_Task() {
while(1) {
OS_Wait_Notification();
timer.HandleDeferred();
}
}
Do you see any disadvantage (other of no-realtime deferred issue) of this solution? Would it work?