3.x: Add fair mode overload to Schedulers.from(Executor) by akarnokd · Pull Request #6744 · ReactiveX/RxJava (original) (raw)

The default Schedulers.from implementation uses an eager approach to execute tasks on the underlying Executor which can lead to excessive thread occupation on its own, even if operators use buffering/prefetch of 1.

This PR introduces a new overload with a fairness option so that tasks are submitted to the Executor in a non-overlapping and FIFO manner one by one.

In addition, the scheduler retention tests have been cleaned up and reworked to not wait unnecessarily long for the GC to finish.

Related: #6696, #6697