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

[v23.3.x] Implement async_for_each #16682

Merged

Conversation

travisdowns
Copy link
Member

@travisdowns travisdowns commented Feb 22, 2024

Backport of #16662.

Fixes #16673.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.3.x
  • v23.2.x
  • v23.1.x

Release Notes

  • none

Same as std::for_each, but which yields periodically. Written in a
style which keeps in inner loop fast, equivalent to the non-async
version (optimizer willing, but seems to be true in the case I
checked).

For the simplest use cases we offer async_for_each, which
is the same as std::for_each except that it yields every
Traits::Interval iterations: every call starts the "work counter" anew.

For more complicated cases, like nested loops, it may be convenient to
carry the counter from one iteration to the next, in order to yield at
the correct times. For example, in a doubly nested loop where the inner
loop always ran for less than Interval iterations, we would not yield
with the simple functions.

Issue redpanda-data/core-internal#1061.

(cherry picked from commit a4c6b64)
(cherry picked from commit e602960)
@travisdowns
Copy link
Member Author

@StephanDollberg straight backport except that I had to change base/seastarx.h to seastarx.h.

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

Successfully merging this pull request may close these issues.

3 participants