Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

Clarification on the Scheduler.Worker.schedule contract #30

Closed
agentgt opened this issue Jun 21, 2019 · 3 comments
Closed

Clarification on the Scheduler.Worker.schedule contract #30

agentgt opened this issue Jun 21, 2019 · 3 comments
Labels

Comments

@agentgt
Copy link

agentgt commented Jun 21, 2019

The Scheduler.Worker#schedule javadoc says:

    /**
     * Creates a worker of this Scheduler that executed task in a strict
     * FIFO order, guaranteed non-concurrently with each other.
     * <p>
     * Once the Worker is no longer in use, one should call shutdown() on it to
     * release any resources the particular Scheduler may have used.
     * 
     * <p>Tasks scheduled with this worker run in FIFO order and strictly non-concurrently, but
     * there are no ordering guarantees between different Workers created from the same
     * Scheduler.
     * 
     * @return the Worker instance.
     */

The FIFO order seems to be preserved in all of the code examples but I don't understand the semantics being used for "strictly non-concurrently".

For example it appears ExecutorServiceScheduler will have Workers that will run tasks concurrently unless a single thread executor is used.

In other Reactive Streams implementations that have a scheduler aka rxjava there is no mention of that guarantee.

Is there some implementation logic I'm missing or am I misunderstanding the doc?

@akarnokd
Copy link
Contributor

Please read the Scheduler JavaDocs.

The so-called Scheduler.Workers of a Scheduler can be created via the createWorker() method which allow the scheduling of multiple Runnable tasks in an isolated manner. Runnable tasks scheduled on a Worker are guaranteed to be executed sequentially and in a non-overlapping fashion. Non-delayed Runnable tasks are guaranteed to execute in a First-In-First-Out order but their execution may be interleaved with delayed tasks. In addition, outstanding or running tasks can be cancelled together via Disposable.dispose() without affecting any other Worker instances of the same Scheduler.

@agentgt
Copy link
Author

agentgt commented Jun 21, 2019

Yes but that is the RxJava documentation of which I'm familiar with and is far more clear. I just thought it might be worthwhile to put something similar in this project.

Edit: what I meant by rxjava "not mentioning" meaning it does not have that guarantee... not that it doesn't explain the interleaving... sorry my mistake for saying that. RxJava has excellent documentation.

@akarnokd
Copy link
Contributor

This project is no longer developed and we applied the knowledge and further clarifications in the respective libraries long ago.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants