@Test public void guardRailsClockIsUsedForStartTime() { long startNanos = 100L; Clock clock = mock(Clock.class); when(guardRail.getClock()).thenReturn(clock); when(clock.nanoTime()).thenReturn(startNanos); service.submit(TestCallable.success(), 100); verify(guardRail).acquirePermits(1L, startNanos); }
public <T> PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable) { PrecipicePromise<TimeoutableResult, T> promise = Asynchronous.acquirePermitsAndPromise(guardRail, 1L); internalComplete(callable, promise); return promise.future(); }
ThreadPoolService implements Precipice<TimeoutableResult, Rejected> { public <T> PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable) { PrecipicePromise<TimeoutableResult, T> promise = Asynchronous.acquirePermitsAndPromise(guardRail, 1L); internalComplete(callable, promise); return promise.future(); } }
ThreadPoolService implements Precipice<TimeoutableResult, Rejected> { public <T> PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable) { PrecipicePromise<TimeoutableResult, T> promise = Asynchronous.acquirePermitsAndPromise(guardRail, 1L); internalComplete(callable, promise); return promise.future(); } ThreadPoolService(int poolSize, int queueSize, GuardRail<TimeoutableResult, Rejected> guardRail);  ThreadPoolService(ExecutorService executorService, GuardRail<TimeoutableResult, Rejected> guardRail); }
ThreadPoolService implements Precipice<TimeoutableResult, Rejected> { public <T> PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable) { PrecipicePromise<TimeoutableResult, T> promise = Asynchronous.acquirePermitsAndPromise(guardRail, 1L); internalComplete(callable, promise); return promise.future(); } ThreadPoolService(int poolSize, int queueSize, GuardRail<TimeoutableResult, Rejected> guardRail);  ThreadPoolService(ExecutorService executorService, GuardRail<TimeoutableResult, Rejected> guardRail); @Override GuardRail<TimeoutableResult, Rejected> guardRail(); PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable); PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable, long millisTimeout); void complete(Callable<T> callable, PrecipicePromise<TimeoutableResult, T> promise); void complete(Callable<T> callable, PrecipicePromise<TimeoutableResult, T> promise, long millisTimeout); ExecutorService getExecutor(); DelayQueueTimeoutService getTimeoutService(); void shutdown(); }
ThreadPoolService implements Precipice<TimeoutableResult, Rejected> { public <T> PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable) { PrecipicePromise<TimeoutableResult, T> promise = Asynchronous.acquirePermitsAndPromise(guardRail, 1L); internalComplete(callable, promise); return promise.future(); } ThreadPoolService(int poolSize, int queueSize, GuardRail<TimeoutableResult, Rejected> guardRail);  ThreadPoolService(ExecutorService executorService, GuardRail<TimeoutableResult, Rejected> guardRail); @Override GuardRail<TimeoutableResult, Rejected> guardRail(); PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable); PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable, long millisTimeout); void complete(Callable<T> callable, PrecipicePromise<TimeoutableResult, T> promise); void complete(Callable<T> callable, PrecipicePromise<TimeoutableResult, T> promise, long millisTimeout); ExecutorService getExecutor(); DelayQueueTimeoutService getTimeoutService(); void shutdown();  }