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.2.x] Implement async_for_each #16683

Merged

Conversation

travisdowns
Copy link
Member

@travisdowns travisdowns commented Feb 22, 2024

Backport of #16662.

Fixes #16672.

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)
@travisdowns
Copy link
Member Author

@StephanDollberg this is straight backport except the base/ removal as with 23.3, and also I dropped the test commit here as gtest doesn't exist in 23.2. The identical code is tested in 23.3.

@travisdowns travisdowns merged commit 97a38be into redpanda-data:v23.2.x Feb 23, 2024
24 checks passed
@BenPope BenPope added this to the v23.2.27 milestone Mar 15, 2024
@BenPope BenPope added the kind/backport PRs targeting a stable branch label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/redpanda kind/backport PRs targeting a stable branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants