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).
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:
Both instants are available to
_is_expired()which servesperiod_completeofPeriodicandis_expiredofOneShot.Considering the
Okresult case, instead of returning abool(expired or not), we should returnOption((ideal_instant, actual_instant)).Extracting the
ideal_instantfrom thePeriodictimer'speriod_completeis particularly useful because it gets updated for the next cycle inside this very function and inspectingexpiredwould already contain the next instant (if it was exposed via accessor).