Skip to content

Add CountDownActionListener #92308

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

Merged
merged 10 commits into from
Dec 19, 2022
Merged

Conversation

joegallo
Copy link
Contributor

It's very similar to GroupedActionListener -- it's basically a purpose-built class for GroupedActionListener<Void> (that is, the existing uses of GroupedActionListener where the results tracking that GroupedActionListener provides is not actually useful).

I originally used CountDown internally (hence the name), but CountDown doesn't validate that you only call it at most N times, so I dropped the use of CountDown in favor of direct invocation counting and being able to do that additional validation.

The part I'm least sure about is the application of this class to existing callers of GroupedActionListener<Void> -- I hunted them with search and replace, but given that there's additional validation that CountDownActionListener is doing it's possible that in some cases that is not actually correct.

Note: I'm happy to back out any or all applications of this to existing code, this class is something I want with more-or-less these semantics for a soon-to-be-existing PR, so even with zero callers in the current codebase it will end up with a caller soon.

Adversarial reviews are most welcome, I really don't want to break anything, and I'm changing a lot of things that I'm not actually all that familiar with.

It's very much like GroupedActionListener, but for when you don't care
about the individual results at all.
It's a common enough calling pattern that it seems handy to add
special support for it.
We don't want to allow too many invocations of the listener
So this is inspired by CountDown, but doesn't *use*
CountDown. Crucially, this gives us the additional validation that you
don't over-invoke the listener -- you get groupSize invocations, no
more.
@joegallo joegallo added >non-issue :Core/Infra/Core Core issues without another label v8.7.0 labels Dec 12, 2022
@joegallo joegallo requested a review from DaveCTurner December 12, 2022 16:51
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Dec 12, 2022
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me, definitely nicer than accumulating an array of null values in all those cases. Haven't looked in detail tho, but I left a suggestion.

@joegallo joegallo requested a review from DaveCTurner December 13, 2022 14:52
Copy link
Contributor

@grcevski grcevski left a comment

Choose a reason for hiding this comment

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

LGTM! This looks pretty good to me. It handles nicely the case where we collect results in vain and the internal logic is pretty much what we have as proven in GroupedActionListener.

Copy link
Member

@thecoop thecoop left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

LGTM3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >non-issue Team:Core/Infra Meta label for core/infra team v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants