Skip to content

Instantly share code, notes, and snippets.

@yangweigbh
Created July 4, 2020 04:25
Show Gist options
  • Save yangweigbh/8f97d61d4bd40d8796d61c389c5806a1 to your computer and use it in GitHub Desktop.
Save yangweigbh/8f97d61d4bd40d8796d61c389c5806a1 to your computer and use it in GitHub Desktop.
fun bumpCurrentThreadPriority() = synchronized(lock) {
val myTid = Process.myTid()
if (initialTid == myTid) {
// already bumped
return
}
// ensure we don't have multiple threads bumped at once
resetBumpedThread()
initialTid = myTid
initialPriority = Process.getThreadPriority(initialTid)
setThreadPriority("Bench thread", initialTid, BENCH_THREAD_PRIORITY)
if (JIT_TID != null) {
setThreadPriority("Jit", JIT_TID, JIT_THREAD_PRIORITY)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment