Skip to content

Commit 9582a5e

Browse files
committed
Merge pull request #3697 from akarnokd/JustFixScheduler
1.x: fix ScalarSynchronousObservable expects EventLoopsScheduler from
2 parents 9f49624 + e953382 commit 9582a5e

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/main/java/rx/internal/util/ScalarSynchronousObservable.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import rx.internal.producers.SingleProducer;
2424
import rx.internal.schedulers.EventLoopsScheduler;
2525
import rx.observers.Subscribers;
26-
import rx.schedulers.Schedulers;
2726

2827
/**
2928
* An Observable that emits a single constant scalar value to Subscribers.
@@ -34,19 +33,6 @@
3433
* @param <T> the value type
3534
*/
3635
public final class ScalarSynchronousObservable<T> extends Observable<T> {
37-
38-
/**
39-
* We expect the Schedulers.computation() to return an EventLoopsScheduler all the time.
40-
*/
41-
static final Func1<Action0, Subscription> COMPUTATION_ONSCHEDULE = new Func1<Action0, Subscription>() {
42-
final EventLoopsScheduler els = (EventLoopsScheduler)Schedulers.computation();
43-
44-
@Override
45-
public Subscription call(Action0 t) {
46-
return els.scheduleDirect(t);
47-
}
48-
};
49-
5036
/**
5137
* Indicates that the Producer used by this Observable should be fully
5238
* threadsafe. It is possible, but unlikely that multiple concurrent
@@ -115,7 +101,13 @@ public T get() {
115101
public Observable<T> scalarScheduleOn(final Scheduler scheduler) {
116102
final Func1<Action0, Subscription> onSchedule;
117103
if (scheduler instanceof EventLoopsScheduler) {
118-
onSchedule = COMPUTATION_ONSCHEDULE;
104+
final EventLoopsScheduler els = (EventLoopsScheduler) scheduler;
105+
onSchedule = new Func1<Action0, Subscription>() {
106+
@Override
107+
public Subscription call(Action0 a) {
108+
return els.scheduleDirect(a);
109+
}
110+
};
119111
} else {
120112
onSchedule = new Func1<Action0, Subscription>() {
121113
@Override

0 commit comments

Comments
 (0)