-
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
rxjava-scala improvements and reimplemented the amb
operator
#952
Conversation
RxJava-pull-requests #887 SUCCESS |
return; | ||
} | ||
observer.onError(e); | ||
subscriber.onError(e); | ||
} | ||
|
||
private boolean isSelected() { |
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.
I wonder if this could be simplified to only a single get() call:
int ch = choice.get();
if (ch == NONE) {
return choice.compareAndSet(NONE, index);
}
return ch == index;
Since this method is called for every onNext() for the winner, this change might reduce the overhead by 2; haven't benchmarked it. In addition, switching to a volatile int choice + double-check synchronization might be a bit faster even. Thoughts?
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.
Not quite sure about "volatile + double-check". If JVM can inline "choice.get()", it should be same as "accessing a volatile var".
RxJava-pull-requests #888 SUCCESS |
rxjava-scala improvements and reimplemented the `amb` operator
This PR did the following improvements:
amb
,delay
,delaySubscription
in rxjava-scala.amb
operator.