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

rxjava-scala improvements and reimplemented the amb operator #952

Merged
merged 6 commits into from
Mar 13, 2014

Conversation

zsxwing
Copy link
Member

@zsxwing zsxwing commented Mar 10, 2014

This PR did the following improvements:

  • Added amb, delay, delaySubscription in rxjava-scala.
  • Reimplemented the amb operator.

@cloudbees-pull-request-builder

RxJava-pull-requests #887 SUCCESS
This pull request looks good

return;
}
observer.onError(e);
subscriber.onError(e);
}

private boolean isSelected() {
Copy link
Member

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?

Copy link
Member Author

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".

@cloudbees-pull-request-builder

RxJava-pull-requests #888 SUCCESS
This pull request looks good

benjchristensen added a commit that referenced this pull request Mar 13, 2014
rxjava-scala improvements and reimplemented the `amb` operator
@benjchristensen benjchristensen merged commit 11e1bd0 into ReactiveX:master Mar 13, 2014
@zsxwing zsxwing deleted the amb branch March 14, 2014 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants