MCPcopy Create free account
hub / github.com/antlr/codebuff / toSafeNanos

Method toSafeNanos

output/java_guava/1.4.16/Monitor.java:974–977  ·  view source on GitHub ↗

Returns unit.toNanos(time), additionally ensuring the returned value is not at risk of overflowing or underflowing, by bounding the value between 0 and (Long.MAX_VALUE / 4) 3. Actually waiting for more than 219 years is not supported!

(long time, TimeUnit unit)

Source from the content-addressed store, hash-verified

972 */
973
974 private static long toSafeNanos(long time, TimeUnit unit) {
975 long timeoutNanos = unit.toNanos(time);
976 return (timeoutNanos <= 0L) ? 0L : (timeoutNanos > (Long.MAX_VALUE / 4) * 3) ? (Long.MAX_VALUE / 4) * 3 : timeoutNanos;
977 }
978
979 /**
980 * Returns System.nanoTime() unless the timeout has already elapsed. Returns 0L if and only if the

Callers 5

enterMethod · 0.95
enterWhenMethod · 0.95
waitForMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected