net.spy.memcached.internal.GetFuture Maven / Gradle / Ivy
The newest version!
package net.spy.memcached.internal;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import net.spy.memcached.ops.Operation;
import net.spy.memcached.ops.OperationStatus;
/**
* Future returned for GET operations.
*
* Not intended for general use.
*
* @param Type of object returned from the get
*/
public class GetFuture implements Future {
private final OperationFuture> rv;
public GetFuture(CountDownLatch l, long opTimeout) {
this.rv = new OperationFuture>(l, opTimeout);
}
public boolean cancel(boolean ign) {
return rv.cancel(ign);
}
public T get() throws InterruptedException, ExecutionException {
Future v = rv.get();
return v == null ? null : v.get();
}
public T get(long duration, TimeUnit units)
throws InterruptedException, TimeoutException, ExecutionException {
Future v = rv.get(duration, units);
return v == null ? null : v.get();
}
public OperationStatus getStatus() {
return rv.getStatus();
}
public void set(Future d, OperationStatus s) {
rv.set(d, s);
}
public void setOperation(Operation to) {
rv.setOperation(to);
}
public boolean isCancelled() {
return rv.isCancelled();
}
public boolean isDone() {
return rv.isDone();
}
}