@Test public void testTimeout() { int timeout = 100; TimeoutTaskMonitor monitor = TimeoutTaskMonitor.timeoutIn(100, TimeUnit.MILLISECONDS); assertFalse(monitor.didTimeout()); sleep(timeout * 2); try { monitor.checkCanceled(); fail(); } catch (TimeoutException e) { } catch (CancelledException e) { fail("Should have a TimeoutException instead of a CancelledException"); } assertTrue(monitor.didTimeout()); }
private void timeout() { didTimeout.set(true); timeoutCallback.call(); cancel(); }
TimeoutTaskMonitor implements TaskMonitor { private void timeout() { didTimeout.set(true); timeoutCallback.call(); cancel(); } }
TimeoutTaskMonitor implements TaskMonitor { private void timeout() { didTimeout.set(true); timeoutCallback.call(); cancel(); } TimeoutTaskMonitor(TaskMonitor delegate, long timeout, TimeUnit timeUnit); }
TimeoutTaskMonitor implements TaskMonitor { private void timeout() { didTimeout.set(true); timeoutCallback.call(); cancel(); } TimeoutTaskMonitor(TaskMonitor delegate, long timeout, TimeUnit timeUnit); static TimeoutTaskMonitor timeoutIn(long timeout, TimeUnit timeUnit); static TimeoutTaskMonitor timeoutIn(long timeout, TimeUnit timeUnit,
			TaskMonitor monitor); void setTimeoutListener(Callback timeoutCallback); boolean didTimeout(); void finished(); @Override boolean isCancelled(); @Override void setShowProgressValue(boolean showProgressValue); @Override void setMessage(String message); @Override void setProgress(long value); @Override void initialize(long max); @Override void setMaximum(long max); @Override long getMaximum(); @Override void setIndeterminate(boolean indeterminate); @Override void checkCanceled(); @Override void incrementProgress(long incrementAmount); @Override long getProgress(); @Override void cancel(); @Override void addCancelledListener(CancelledListener listener); @Override void removeCancelledListener(CancelledListener listener); @Override void setCancelEnabled(boolean enable); @Override boolean isCancelEnabled(); @Override void clearCanceled(); }
TimeoutTaskMonitor implements TaskMonitor { private void timeout() { didTimeout.set(true); timeoutCallback.call(); cancel(); } TimeoutTaskMonitor(TaskMonitor delegate, long timeout, TimeUnit timeUnit); static TimeoutTaskMonitor timeoutIn(long timeout, TimeUnit timeUnit); static TimeoutTaskMonitor timeoutIn(long timeout, TimeUnit timeUnit,
			TaskMonitor monitor); void setTimeoutListener(Callback timeoutCallback); boolean didTimeout(); void finished(); @Override boolean isCancelled(); @Override void setShowProgressValue(boolean showProgressValue); @Override void setMessage(String message); @Override void setProgress(long value); @Override void initialize(long max); @Override void setMaximum(long max); @Override long getMaximum(); @Override void setIndeterminate(boolean indeterminate); @Override void checkCanceled(); @Override void incrementProgress(long incrementAmount); @Override long getProgress(); @Override void cancel(); @Override void addCancelledListener(CancelledListener listener); @Override void removeCancelledListener(CancelledListener listener); @Override void setCancelEnabled(boolean enable); @Override boolean isCancelEnabled(); @Override void clearCanceled();  }