-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
APIs for easily changing the thread priority of default schedulers via hook. #3724
Comments
Happy to do some of the work if this sounds acceptable. |
@JakeWharton I think that sound acceptable, I'm happy to review your PR. |
This is a little more tricky than I had initially anticipated. Perhaps it's worth talking about a means of setting the default priority of the internal thread pools through a mechanism like properties as a separate, easier first step? Plus that would be a lot lower-overhead for Android users anyway, and we could even use the existing Android platform detection to lower the thread priority by default. |
Pass a ThreadFactory
…On Fri, Jan 20, 2017, 10:48 PM erDaren ***@***.***> wrote:
so, how to set thread priority in android with android values(like
Process.THREAD_PRIORITY_BACKGROUND)?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3724 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEEEUOSEQqdFAeQocjdNnUfjwJ8gjubks5rUaorgaJpZM4Heynt>
.
|
On Android, the main thread is a sacred holy land at which we must all worship. As such this means other threads (ideally) shouldn't be favorably scheduled in priority with it. For network and filesystem operations this usually means using low priority threads.
One solution is to just use low priority threads on our own schedulers, but this doesn't affect code using the standard
io()
andcomputation()
schedulers. Unfortunately there's a whole bunch of ceremony around how various schedulers are initialized which includes a mixed bag of public vs. non-public types and APIs which makes replacing them in a scheduler hook difficult.I think the most easy way to accomplish this is the following:
Not needed.RxThreadFactory
constructor overload which takes a thread priority to use.Schedulers
for creating instances ofio()
,computation()
, andnewThread()
except using a suppliedThreadFactory
Schedulers.createIoScheduler(ThreadFactory)
Schedulers.createComputationScheduler(ThreadFactory)
Schedulers.createNewThreadScheduler(ThreadFactory)
Nice to have:
Schedulers
using these factory methods to create the default implementations. This involves moving the thread factories from the individual types "up" toShedulers
.The text was updated successfully, but these errors were encountered: