From e9533824ba932500e3cfc40aa0c6fd2cfc3036ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Karnok?= Date: Thu, 11 Feb 2016 23:54:47 +0100 Subject: [PATCH] 1.x: fix ScalarSynchronousObservable expects EventLoopsScheduler from Schedulers.computation() --- .../util/ScalarSynchronousObservable.java | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main/java/rx/internal/util/ScalarSynchronousObservable.java b/src/main/java/rx/internal/util/ScalarSynchronousObservable.java index f4c8c3cd2e..ecb5c18d98 100644 --- a/src/main/java/rx/internal/util/ScalarSynchronousObservable.java +++ b/src/main/java/rx/internal/util/ScalarSynchronousObservable.java @@ -23,7 +23,6 @@ import rx.internal.producers.SingleProducer; import rx.internal.schedulers.EventLoopsScheduler; import rx.observers.Subscribers; -import rx.schedulers.Schedulers; /** * An Observable that emits a single constant scalar value to Subscribers. @@ -34,19 +33,6 @@ * @param the value type */ public final class ScalarSynchronousObservable extends Observable { - - /** - * We expect the Schedulers.computation() to return an EventLoopsScheduler all the time. - */ - static final Func1 COMPUTATION_ONSCHEDULE = new Func1() { - final EventLoopsScheduler els = (EventLoopsScheduler)Schedulers.computation(); - - @Override - public Subscription call(Action0 t) { - return els.scheduleDirect(t); - } - }; - /** * Indicates that the Producer used by this Observable should be fully * threadsafe. It is possible, but unlikely that multiple concurrent @@ -115,7 +101,13 @@ public T get() { public Observable scalarScheduleOn(final Scheduler scheduler) { final Func1 onSchedule; if (scheduler instanceof EventLoopsScheduler) { - onSchedule = COMPUTATION_ONSCHEDULE; + final EventLoopsScheduler els = (EventLoopsScheduler) scheduler; + onSchedule = new Func1() { + @Override + public Subscription call(Action0 a) { + return els.scheduleDirect(a); + } + }; } else { onSchedule = new Func1() { @Override