@Test public void submittedCallableWillTimeout() throws Exception { when(guardRail.acquirePermits(eq(1L), anyLong())).thenReturn(null); CountDownLatch latch = new CountDownLatch(1); PrecipiceFuture<TimeoutableResult, String> future = service.submit(TestCallable.blocked(latch), 1); try { future.get(); fail("Should have thrown ExecutionException from PrecipiceTimeoutException"); } catch (ExecutionException e) { assertTrue(e.getCause() instanceof PrecipiceTimeoutException); } assertEquals(TimeoutableResult.TIMEOUT, future.getResult()); assertTrue(future.getError() instanceof PrecipiceTimeoutException); latch.countDown(); }
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();  }