mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-07-06 09:00:00 +00:00
54 lines
1.3 KiB
Java
54 lines
1.3 KiB
Java
package com.sk89q.worldedit.util.task;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.Future;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeoutException;
|
|
|
|
public class LinkedFuture<T extends Future<T>> implements Future<T> {
|
|
private Future<T> task;
|
|
|
|
public LinkedFuture(Future<T> task) {
|
|
this.task = task;
|
|
}
|
|
|
|
@Override
|
|
public boolean cancel(boolean mayInterruptIfRunning) {
|
|
return task.cancel(mayInterruptIfRunning);
|
|
}
|
|
|
|
@Override
|
|
public boolean isCancelled() {
|
|
return task.isCancelled();
|
|
}
|
|
|
|
@Override
|
|
public boolean isDone() {
|
|
return task.isDone();
|
|
}
|
|
|
|
@Override
|
|
public synchronized T get() throws InterruptedException, ExecutionException {
|
|
if (task != null) {
|
|
task = task.get();
|
|
if (task != null) {
|
|
return (T) this;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public synchronized T get(long timeout, @NotNull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
|
|
if (task != null) {
|
|
task = task.get(timeout, unit);
|
|
if (task != null) {
|
|
return (T) this;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|