-
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
Porting the Scheduler.when operator from 1.x to 2.x #4827
Conversation
final Worker actualWorker = actualScheduler.createWorker(); | ||
// a queue for the actions submitted while worker is waiting to get to | ||
// the subscribe to off the workerQueue. | ||
ReplaySubject<ScheduledAction> actionSubject = ReplaySubject.create(); |
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.
You can use a ReplayProcessor
instead.
Flowable<Completable> actions = actionSubject.toFlowable(BackpressureStrategy.BUFFER).map(new Function<ScheduledAction, Completable>() { | ||
@Override | ||
public Completable apply(final ScheduledAction action) { | ||
return Completable.unsafeCreate(new CompletableSource() { |
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.
No need for such indirection, just extend Completable
:
return new Completable() {
@Override
public void subscribeActual(CompletableObserver actionCompletable) {
actionCompletable.onSubscribe(action);
action.call(actualWorker, actionCompletable);
}
};
import java.util.concurrent.atomic.AtomicBoolean; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
import org.openjdk.jmh.runner.RunnerException; |
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 is not available in the main build.
https://travis-ci.org/ReactiveX/RxJava/builds/174626634#L169
ed1dcb3
to
ad5ab3a
Compare
Current coverage is 95.66% (diff: 76.31%)@@ 2.x #4827 diff @@
==========================================
Files 570 571 +1
Lines 36723 36799 +76
Methods 0 0
Messages 0 0
Branches 5556 5563 +7
==========================================
+ Hits 35143 35202 +59
- Misses 651 663 +12
- Partials 929 934 +5
|
In fixing the Scheduler.when in 1.x I noticed that it hadn't been ported to 2.x. This PR tries to fix that translating Observable to Flowable and Subscription to Disposable. This also includes the fix from 1.x