Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa8501d1 authored by Hans Boehm's avatar Hans Boehm
Browse files

Make setThreadPriority(int) cooperate with cache

The java.lang.Thread implementation caches Java priorities. Route
android.os.Process.setThreadPriority(int) requests through that cache.

This makes android.os.Process.setThreadPriority(int) compatible with
ART's temporary priority changes. In the future it may make similar,
less race-prone, temporary priority increases possible in other code.

This is important since we recommend setThreadPriority on thread start
(see https://developer.android.com/topic/performance/threads#priority).
It should not handicap ART performance.

(If we could design these APIs from scratch, there is much I would
change, but ...)

Improve the Process documentation by documenting existing important
behavior that surprised me. Nothing here is inconsistent with the
old spec, or changes anything other than performance.

Update some other documentation to reflect the new reality.
ThreadPriorityBooster may be worth future re-examination.

Have all versions of setThreadPriority throw an
IllegalArgumentException for priority arguments outside [-20, 19].

Bug: 417492941
Flag: com.android.libcore.niceness_apis
Test: atest ProcessTest, choosing the modified test
Change-Id: I46fea0357a843d9f64f93eb6880951c4c9432d54
parent 1b105a76
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment