Bug 897123 - Make GeckoAppShell.pumpMessageLoop waste less CPU time r=jchen
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
package org.mozilla.gecko.util;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.MessageQueue;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -14,11 +15,17 @@ public final class ThreadUtils {
|
||||
private static final String LOGTAG = "ThreadUtils";
|
||||
|
||||
private static Thread sUiThread;
|
||||
private static Thread sGeckoThread;
|
||||
private static Thread sBackgroundThread;
|
||||
|
||||
private static Handler sUiHandler;
|
||||
private static Handler sGeckoHandler;
|
||||
|
||||
// Referenced directly from GeckoAppShell in highly performance-sensitive code (The extra
|
||||
// function call of the getter was harming performance. (Bug 897123))
|
||||
// Once Bug 709230 is resolved we should reconsider this as ProGuard should be able to optimise
|
||||
// this out at compile time.
|
||||
public static Handler sGeckoHandler;
|
||||
public static MessageQueue sGeckoQueue;
|
||||
public static Thread sGeckoThread;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class UiThreadBlockedException extends RuntimeException {
|
||||
@@ -56,11 +63,6 @@ public final class ThreadUtils {
|
||||
sUiHandler = handler;
|
||||
}
|
||||
|
||||
public static void setGeckoThread(Thread thread, Handler handler) {
|
||||
sGeckoThread = thread;
|
||||
sGeckoHandler = handler;
|
||||
}
|
||||
|
||||
public static void setBackgroundThread(Thread thread) {
|
||||
sBackgroundThread = thread;
|
||||
}
|
||||
@@ -77,14 +79,6 @@ public final class ThreadUtils {
|
||||
sUiHandler.post(runnable);
|
||||
}
|
||||
|
||||
public static Thread getGeckoThread() {
|
||||
return sGeckoThread;
|
||||
}
|
||||
|
||||
public static Handler getGeckoHandler() {
|
||||
return sGeckoHandler;
|
||||
}
|
||||
|
||||
public static Thread getBackgroundThread() {
|
||||
return sBackgroundThread;
|
||||
}
|
||||
@@ -102,7 +96,7 @@ public final class ThreadUtils {
|
||||
}
|
||||
|
||||
public static void assertOnGeckoThread() {
|
||||
assertOnThread(getGeckoThread());
|
||||
assertOnThread(sGeckoThread);
|
||||
}
|
||||
|
||||
public static void assertOnBackgroundThread() {
|
||||
|
||||
Reference in New Issue
Block a user