зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1041906 Use AtomicReference for GeckoThread LaunchState. r=rnewman
This commit is contained in:
Родитель
33e55bd7d7
Коммит
a538bfc7b0
|
@ -22,6 +22,7 @@ import android.util.Log;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class GeckoThread extends Thread implements GeckoEventListener {
|
||||
private static final String LOGTAG = "GeckoThread";
|
||||
|
@ -34,9 +35,10 @@ public class GeckoThread extends Thread implements GeckoEventListener {
|
|||
GeckoRunning,
|
||||
GeckoExiting,
|
||||
GeckoExited
|
||||
};
|
||||
}
|
||||
|
||||
private static LaunchState sLaunchState = LaunchState.Launching;
|
||||
private static AtomicReference<LaunchState> sLaunchState =
|
||||
new AtomicReference<LaunchState>(LaunchState.Launching);
|
||||
|
||||
private static GeckoThread sGeckoThread;
|
||||
|
||||
|
@ -176,8 +178,6 @@ public class GeckoThread extends Thread implements GeckoEventListener {
|
|||
GeckoAppShell.runGecko(path, args, mUri, type);
|
||||
}
|
||||
|
||||
private static Object sLock = new Object();
|
||||
|
||||
@Override
|
||||
public void handleMessage(String event, JSONObject message) {
|
||||
if ("Gecko:Ready".equals(event)) {
|
||||
|
@ -189,15 +189,11 @@ public class GeckoThread extends Thread implements GeckoEventListener {
|
|||
|
||||
@RobocopTarget
|
||||
public static boolean checkLaunchState(LaunchState checkState) {
|
||||
synchronized (sLock) {
|
||||
return sLaunchState == checkState;
|
||||
}
|
||||
return sLaunchState.get() == checkState;
|
||||
}
|
||||
|
||||
static void setLaunchState(LaunchState setState) {
|
||||
synchronized (sLock) {
|
||||
sLaunchState = setState;
|
||||
}
|
||||
sLaunchState.set(setState);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -205,11 +201,6 @@ public class GeckoThread extends Thread implements GeckoEventListener {
|
|||
* state is <code>checkState</code>; otherwise do nothing and return false.
|
||||
*/
|
||||
static boolean checkAndSetLaunchState(LaunchState checkState, LaunchState setState) {
|
||||
synchronized (sLock) {
|
||||
if (sLaunchState != checkState)
|
||||
return false;
|
||||
sLaunchState = setState;
|
||||
return true;
|
||||
}
|
||||
return sLaunchState.compareAndSet(checkState, setState);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче