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

✨ Add periodic adapter #152

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

✨ Add periodic adapter #152

wants to merge 1 commit into from

Conversation

elbeno
Copy link
Contributor

@elbeno elbeno commented Feb 20, 2025

Problem:

  • There is no way to periodically run a sender without drift.

Solution:

  • Introduce periodic, periodic_n, and periodic_until.

Notes:

  • periodic interacts with the durationless time_scheduler. On first start, it schedules an expiry time of now + duration. On subsequent starts, it schedules an expiry time of previous expiry + duration. In this way it eliminates drift caused by the small amount of time taken to manage the timer interrupt.
  • The get_expiration query returns an expiration_provider rather than a bare expiration time because computing an expiration time typically involves calling HAL::now(), which entails making sure that HAL::enable() has been called.

@elbeno elbeno force-pushed the periodic branch 3 times, most recently from 45c014b to 4205032 Compare February 20, 2025 21:47
Problem:
- There is no way to periodically run a sender without drift.

Solution:
- Introduce `periodic`, `periodic_n`, and `periodic_until`.

Notes:
- `periodic` interacts with the durationless time_scheduler. On first `start`,
  it schedules an expiry time of `now + duration`. On subsequence `start`s, it
  schedules an expiry time of `previous expiry + duration`. In this way it
  eliminates drift caused by the small amount of time taken to manage the
  timer interrupt.
- The `get_expiration` query returns an `expiration_provider` rather than a bare
  expiration time because computing an expiration time typically involves
  calling `HAL::now()`, which entails making sure that `HAL::enable`
  has been called.

TEST_CASE("periodic propagates forwarding queries to its child environment",
"[periodic]") {
auto s = custom_sender{};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: This doesn't seem to be testing anything in periodic. What am I missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 88 is testing periodic; like 85 is the basis. It's testing that periodic correctly handles a forwarding query to its attributes.

@@ -12,11 +13,25 @@ constexpr inline struct get_expiration_t : forwarding_query_t {
constexpr static auto name = stdx::ct_string{"get_expiration"};

template <typename T>
requires true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: What does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It more tightly constrains this overload versus the one on line 28.

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

Successfully merging this pull request may close these issues.

2 participants