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

Method create

output/java_guava/1.4.17/TimeoutFuture.java:38–48  ·  view source on GitHub ↗
(
    ListenableFuture<V> delegate,
    long time,
    TimeUnit unit,
    ScheduledExecutorService scheduledExecutor)

Source from the content-addressed store, hash-verified

36@GwtIncompatible
37final class TimeoutFuture<V> extends AbstractFuture.TrustedFuture<V> {
38 static <V> ListenableFuture<V> create(
39 ListenableFuture<V> delegate,
40 long time,
41 TimeUnit unit,
42 ScheduledExecutorService scheduledExecutor) {
43 TimeoutFuture<V> result = new TimeoutFuture<V>(delegate);
44 TimeoutFuture.Fire<V> fire = new TimeoutFuture.Fire<V>(result);
45 result.timer = scheduledExecutor.schedule(fire, time, unit);
46 delegate.addListener(fire, directExecutor());
47 return result;
48 }
49
50 /*
51 * Memory visibility of these fields. There are two cases to consider.

Callers 1

withTimeoutMethod · 0.95

Calls 3

scheduleMethod · 0.65
addListenerMethod · 0.65
directExecutorMethod · 0.45

Tested by

no test coverage detected