Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: deferred timers #952

Open
KammutierSpule opened this issue Sep 7, 2024 · 0 comments
Open

Feature request: deferred timers #952

KammutierSpule opened this issue Sep 7, 2024 · 0 comments

Comments

@KammutierSpule
Copy link

KammutierSpule commented Sep 7, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant