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

1.x: fix observeOn resource handling, add delayError capability #3544

Closed
wants to merge 1 commit into from

Conversation

akarnokd
Copy link
Member

This PR fixes the "messing around" reported in #3002 and adds an overload to observeOn that allows delaying errors without the need for wrapping (see #3542 and maybe there are other reports).

In addition, this PR adds a proper override of the isEmpty method to simply compare the two indexes for emptiness directly instead of size() == 0 to avoid looping, multi-reading and casting.

Benchmark comparison (i7 4790, Windows 7 x64, Java 8u66):

image

Note that the benchmark is generally quite noisy, yielding hectic results (i.e., firing up a thread with newThread may take quite some random microseconds). For example, observeOnImmediate shouldn't be affected by any of the changes yet the run-to-run variance is +/- 10%. I'm fine with the results of the benchmark.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@akarnokd akarnokd added this to the 1.0.x milestone Nov 27, 2015
@artem-zinnatullin
Copy link
Contributor

I like the change, but can't we ship this behavior as default? Yes, it's a breaking change, but in a good way. I mean, I'm just not sure that a lot of users will even know about this operator and even less will understand the difference and situations when they'll need to use one instead of another.

@@ -145,106 +150,126 @@ public void onCompleted() {
@Override
public void onError(final Throwable e) {
if (isUnsubscribed() || finished) {
RxJavaPlugins.getInstance().getErrorHandler().handleError(e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like a candidate for a separate PR, isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

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

More PRs to the same class ends up being merged much later and usually in the wrong order.

@stealthcode
Copy link

@akarnokd are you concerned by the performance impacts of this PR?

@akarnokd
Copy link
Member Author

akarnokd commented Dec 8, 2015

No concerns.

ts.assertNoErrors();
ts.assertNotCompleted();

ts.requestMore(3); // requesting 2 doesn't switch to the error() source for some reason in concat.
Copy link
Member

Choose a reason for hiding this comment

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

Any idea why requesting 2 didn't work?

Copy link
Member Author

Choose a reason for hiding this comment

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

The drain loop quits because it runs out of requests but at the same time, the concatenated data source is also empty. I can add a if (checkTerminated(finished, q.isEmpty(), localChild, q)) return check again, but this adds overhead for those sources that request again anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Ok I see, thanks for the detailed explanation.

@stevegury
Copy link
Member

👍

@akarnokd
Copy link
Member Author

akarnokd commented Dec 9, 2015

Since this adds to the API surface, can I have another +1? (Also feel free to merge this.)

@akarnokd
Copy link
Member Author

akarnokd commented Feb 9, 2016

Closing and reposting again with proper rebase.

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.

None yet

4 participants