Commit a9ed6b19 by andrewlewis Committed by Oliver Woodman

Switch from currentTimeMillis to elapsedRealtime

currentTimeMillis is not guaranteed to be monotonic and elapsedRealtime is
recommend for interval timing.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176853118
parent c4385c73
......@@ -60,18 +60,18 @@ public final class ConditionVariable {
}
/**
* Blocks until the condition is opened or until timeout milliseconds have passed.
* Blocks until the condition is opened or until {@code timeout} milliseconds have passed.
*
* @param timeout The maximum time to wait in milliseconds.
* @return true If the condition was opened, false if the call returns because of the timeout.
* @return True if the condition was opened, false if the call returns because of the timeout.
* @throws InterruptedException If the thread is interrupted.
*/
public synchronized boolean block(long timeout) throws InterruptedException {
long now = System.currentTimeMillis();
long now = android.os.SystemClock.elapsedRealtime();
long end = now + timeout;
while (!isOpen && now < end) {
wait(end - now);
now = System.currentTimeMillis();
now = android.os.SystemClock.elapsedRealtime();
}
return isOpen;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment