Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions src/main/java/rx/internal/util/ScalarSynchronousObservable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -34,19 +33,6 @@
* @param <T> the value type
*/
public final class ScalarSynchronousObservable<T> extends Observable<T> {

/**
* We expect the Schedulers.computation() to return an EventLoopsScheduler all the time.
*/
static final Func1<Action0, Subscription> COMPUTATION_ONSCHEDULE = new Func1<Action0, Subscription>() {
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
Expand Down Expand Up @@ -115,7 +101,13 @@ public T get() {
public Observable<T> scalarScheduleOn(final Scheduler scheduler) {
final Func1<Action0, Subscription> onSchedule;
if (scheduler instanceof EventLoopsScheduler) {
onSchedule = COMPUTATION_ONSCHEDULE;
final EventLoopsScheduler els = (EventLoopsScheduler) scheduler;
onSchedule = new Func1<Action0, Subscription>() {
@Override
public Subscription call(Action0 a) {
return els.scheduleDirect(a);
}
};
} else {
onSchedule = new Func1<Action0, Subscription>() {
@Override
Expand Down