ReactiveX / RxAndroid

RxJava bindings for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why the HandlerScheduler class overrides scheduleDirect. It's not more explicit to let the HandlerWorker do the work

notcaremath opened this issue · comments

Why the HandlerScheduler class overrides scheduleDirect. It's not more explicit to let the HandlerWorker do the work

A worker implementation is required to track all submitted tasks so they can be mass disposed. That adds overhead to use cases where only individual tasks need to be submitted. Such tasks are either tracked outside the scheduler or don't really need tracking.

I still don't understand why HandlerScheduler overrides the scheduleDirect method instead of using the Scheduler superclass method like IoScheduler and NewThreadScheduler

To avoid the uneccessary overhead of going through the HandlerWorker, as this particular type of scheduler can. Same logic as with Schedulers.single().

thank you very much for your help