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

Expose Timer's Expiration Time #131

Open
Felix-El opened this issue Dec 30, 2022 · 0 comments
Open

Expose Timer's Expiration Time #131

Felix-El opened this issue Dec 30, 2022 · 0 comments

Comments

@Felix-El
Copy link

After waiting on/polling for a timer's completion, I would want to know which time it is now, without potential overhead of calling try_now() again.

This story actually asks for two instants:

  • one is the ideal expiration instant which is a private data member of Timers already
  • the other is the actual instant read from the Clock and found to be greater than or equal the ideal one during the query

Both instants are available to _is_expired() which serves period_complete of Periodic and is_expired of OneShot.

Considering the Ok result case, instead of returning a bool (expired or not), we should return Option((ideal_instant, actual_instant)).
Extracting the ideal_instant from the Periodic timer's period_complete is particularly useful because it gets updated for the next cycle inside this very function and inspecting expired would already contain the next instant (if it was exposed via accessor).

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