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

Method toSafeNanos

output/java_guava/1.4.19/Monitor.java:972–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

970 */
971
972 private static long toSafeNanos(long time, TimeUnit unit) {
973 long timeoutNanos = unit.toNanos(time);
974 return (timeoutNanos <= 0L) ? 0L : (timeoutNanos > (Long.MAX_VALUE / 4) * 3)
975 ? (Long.MAX_VALUE / 4) * 3
976 : 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