Skip to content

rxjava-scala improvements and reimplemented the amb operator#952

Merged
benjchristensen merged 6 commits intoReactiveX:masterfrom
zsxwing:amb
Mar 13, 2014
Merged

rxjava-scala improvements and reimplemented the amb operator#952
benjchristensen merged 6 commits intoReactiveX:masterfrom
zsxwing:amb

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

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.

4 participants