Codemod realtime to CLOCK_MONOTONIC where it makes sense

Reviewed By: rickbrew

Differential Revision: D2860798

fb-gh-sync-id: 35cd188091f6f790809afed81529531850f82d85
This commit is contained in:
Daniel Colascione 2016-01-27 21:55:24 -08:00 committed by facebook-github-bot-4
parent f7c48ee0ce
commit 96a3a8e9b9
1 changed files with 7 additions and 7 deletions

View File

@ -36,16 +36,16 @@ public class ReactIdleDetectionUtil {
long timeoutMs) {
UiThreadUtil.assertNotOnUiThread();
long startTime = SystemClock.elapsedRealtime();
long startTime = SystemClock.uptimeMillis();
waitInner(idleSignaler, timeoutMs);
long timeToWait = Math.max(1, timeoutMs - (SystemClock.elapsedRealtime() - startTime));
long timeToWait = Math.max(1, timeoutMs - (SystemClock.uptimeMillis() - startTime));
waitForChoreographer(timeToWait);
waitForJSIdle(reactContext);
timeToWait = Math.max(1, timeoutMs - (SystemClock.elapsedRealtime() - startTime));
timeToWait = Math.max(1, timeoutMs - (SystemClock.uptimeMillis() - startTime));
waitInner(idleSignaler, timeToWait);
timeToWait = Math.max(1, timeoutMs - (SystemClock.elapsedRealtime() - startTime));
timeToWait = Math.max(1, timeoutMs - (SystemClock.uptimeMillis() - startTime));
waitForChoreographer(timeToWait);
}
@ -108,15 +108,15 @@ public class ReactIdleDetectionUtil {
private static void waitInner(ReactBridgeIdleSignaler idleSignaler, long timeToWait) {
// TODO gets broken in gradle, do we need it?
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
long startTime = SystemClock.elapsedRealtime();
long startTime = SystemClock.uptimeMillis();
boolean bridgeWasIdle = false;
while (SystemClock.elapsedRealtime() - startTime < timeToWait) {
while (SystemClock.uptimeMillis() - startTime < timeToWait) {
boolean bridgeIsIdle = idleSignaler.isBridgeIdle();
if (bridgeIsIdle && bridgeWasIdle) {
return;
}
bridgeWasIdle = bridgeIsIdle;
long newTimeToWait = Math.max(1, timeToWait - (SystemClock.elapsedRealtime() - startTime));
long newTimeToWait = Math.max(1, timeToWait - (SystemClock.uptimeMillis() - startTime));
idleSignaler.waitForIdle(newTimeToWait);
instrumentation.waitForIdleSync();
}