-
Notifications
You must be signed in to change notification settings - Fork 7.6k
3.x: constrain upstream requests from take, remove limit operator #6650
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
Conversation
Codecov Report
@@ Coverage Diff @@
## 3.x #6650 +/- ##
============================================
- Coverage 98.11% 98.08% -0.04%
+ Complexity 6191 6186 -5
============================================
Files 678 677 -1
Lines 44722 44674 -48
Branches 6176 6166 -10
============================================
- Hits 43880 43818 -62
- Misses 294 302 +8
- Partials 548 554 +6
Continue to review full report at Codecov.
|
if (!get() && compareAndSet(false, true)) { | ||
if (n >= limit) { | ||
upstream.request(Long.MAX_VALUE); | ||
while (true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the limit() internals?
* Limits both the number of upstream items (after which the sequence completes) | ||
* and the total downstream request amount requested from the upstream to | ||
* possibly prevent the creation of excess items by the upstream. | ||
* <p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Javadoc of take should contain these extra information.
Why not simply delete |
Indeed! Will do. |
c2d9279
to
c499746
Compare
c499746
to
426c817
Compare
Copied code from |
As per discussion in #6569, this PR constrains upstream requests from the
take
operator and removes thelimit
operator.I've also added a couple of unit tests for coverage of
elementAt
that I didn't include in #6620.