Skip to content
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

Requirement for Scheduler #15

Open
benjchristensen opened this issue Jun 5, 2015 · 4 comments
Open

Requirement for Scheduler #15

benjchristensen opened this issue Jun 5, 2015 · 4 comments
Labels

Comments

@benjchristensen
Copy link
Member

Right now the API requires defining a Scheduler. Why is that required?

I see two possible defaults:

  1. It just runs on the thread ListenableFuture calls back on
  2. 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.

@benjchristensen
Copy link
Member Author

cc @abersnaze

@abersnaze
Copy link
Contributor

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?

@benjchristensen
Copy link
Member Author

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.

@Crystark
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants