List of usage examples for com.google.common.util.concurrent AbstractFuture isCancelled
@Override public boolean isCancelled()
From source file:org.jclouds.compute.callables.BlockUntilInitScriptStatusIsZeroThenReturnOutput.java
/** * make sure we stop the retry loop if someone cancelled the future, this keeps threads from * being consumed on dead tasks/*from w ww . jav a 2s .c om*/ */ static Predicate<String> loopUntilTrueOrThrowCancellationException(Predicate<String> predicate, long period, long maxPeriod, final AbstractFuture<ExecResponse> futureWhichMightBeCancelled) { return retry(Predicates.<String>and(predicate, new Predicate<String>() { public boolean apply(String in) { if (futureWhichMightBeCancelled.isCancelled()) throw new CancellationException(futureWhichMightBeCancelled + " is cancelled"); return true; } }), period, maxPeriod, MILLISECONDS); }