-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Fix issue #1522 #1523
Fix issue #1522 #1523
Conversation
RxJava-pull-requests #1441 SUCCESS |
RxJava-pull-requests #1442 SUCCESS |
RxJava-pull-requests #1443 SUCCESS |
RxJava-pull-requests #1445 SUCCESS |
// Therefore, always check before setting to `c+n` | ||
return; | ||
} | ||
if (REQUESTED_UPDATER.compareAndSet(this, _c, _c + n)) { |
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.
This can still just use getAndAdd without the CAS retry loop.
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.
Here I try to ignore the further requests after request(Long.MAX_VALUE)
. I cannot use getAndAdd
because if requested == Long.MAX_VALUE
, I wanna ignore n
. If adding n
to requested
, and if it happens to execute in while (true)
loop in emit
method, the loop won't stop because requested < 0
.
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.
For the overflow, I mean sending a request(n)
after request(Long.MAX_VALUE)
may make requested
overflow easily. c+n
is rarely overflow if request != Long.MAX_VALUE
(However, we still can handle c+n
overflow problem by adding a check c > Long.MAX_VALUE - n
).
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.
If we keep the fast path we can just check that request is MAX_VALUE then skip. For example: https://github.com/Netflix/RxJava/blob/bb56093c00185dbd39785a95197abe4b66f3bbca/rxjava-core/src/main/java/rx/internal/operators/OnSubscribeRange.java#L59
RxJava-pull-requests #1450 FAILURE |
Signed-off-by: zsxwing <[email protected]>
RxJava-pull-requests #1453 SUCCESS |
@@ -60,6 +60,9 @@ public void onNext(T value) { | |||
} else { | |||
this.value = value; | |||
isNonEmpty = true; | |||
// Issue: https://github.com/Netflix/RxJava/pull/1527 | |||
// Because we cache a value and don't emit now, we need to request another one. |
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.
Good catch.
I think this looks good, though I'm still curious if the complexity here is worth us having a fast-path. Would be interesting to do JMH testing. In |
TakeLast
should ignore otherrequest
s if it's requested withLong.MAX_VALUE
. #1522