RxJavaGuava
RxJavaGuava copied to clipboard
Requirement for Scheduler
Right now the API requires defining a Scheduler. Why is that required?
I see two possible defaults:
- It just runs on the thread ListenableFuture calls back on
- It can be scheduled on Scheduler.computation() by default
I think (1) is the correct default. Someone can use observeOn
if they want to move the scheduling. Thus, I don't fully understand why Scheduler
even needs to be passed in.
cc @abersnaze
The API for a ListenableFuture
requires you to specify the Executor
to schedule the completion callback on. By not adding one in version 1 left it open for adding a overload in the future. Is there is a reasonable default Scheduler
/Executor
?
Well that's an awkward callback then. It means it always gets scheduled. Annoying.
I would default to computation like everything else does since this is pure compute, no IO for emitting the result.
Hi @benjchristensen, @abersnaze
Just as a follow up on this, would it be OK to have the following:
public static <T> Observable<T> from(final ListenableFuture<T> future) {
from(future, Schedulers.computation());
}
and then use
ListenableFutureObservable.from(myFuture)
.observeOn(Schedulers.io());
I'm asking for a use in the Cassandra driver context which returns a guava ListenableFuture.
I'm still struggling to understand what the real impact of using a scheduler or an other and how the processing switches from one thread to another.
In my use case I guess I could just use from(cassandraFuture, Schedulers.io())
but i'd like to understand a bit more what i'm doing with this.
Thanks