All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.algorithmia.algo.FutureAlgoResponse Maven / Gradle / Ivy

There is a newer version: 1.0.16
Show newest version
package com.algorithmia.algo;

import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.lang.InterruptedException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

/**
 * A request object to represent that an algorithm has been call asynchronously
 * Wrapping {@code Future } will allow other async scenarios
 * (e.g. where the internal implementation is based on polling instead of long-lived connections)
 * without changing the exposed interface
 */
public class FutureAlgoResponse implements Future {
    protected Future promise;

    protected FutureAlgoResponse () {}

    public FutureAlgoResponse(Future promise) {
        this.promise = promise;
    }

    public boolean cancel(boolean mayInterruptIfRunning) {
        return promise.cancel(mayInterruptIfRunning);
    }

    public boolean isCancelled() {
        return promise.isCancelled();
    }

    public boolean isDone() {
        return promise.isDone();
    }

    public AlgoResponse get() throws InterruptedException, ExecutionException {
        return promise.get();
    }

    public AlgoResponse get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
        return promise.get(timeout, unit);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy