Example usage for com.google.common.util.concurrent AbstractFuture isCancelled

List of usage examples for com.google.common.util.concurrent AbstractFuture isCancelled

Introduction

In this page you can find the example usage for com.google.common.util.concurrent AbstractFuture isCancelled.

Prototype

@Override
    public boolean isCancelled() 

Source Link

Usage

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);
}