mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-05 11:53:53 +00:00
54 lines
1.6 KiB
Java
54 lines
1.6 KiB
Java
package com.sap.sse.util.impl;
|
|
|
|
import java.util.concurrent.Delayed;
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.RunnableScheduledFuture;
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeoutException;
|
|
|
|
public class ThreadPoolAwareRunnableScheduledFutureDelegate<V> extends KnowsExecutorAndTracingGetImpl<V> implements KnowsExecutorAndTracingGet<V>, RunnableScheduledFuture<V> {
|
|
private final RunnableScheduledFuture<V> future;
|
|
|
|
public ThreadPoolAwareRunnableScheduledFutureDelegate(ThreadPoolExecutor executor, RunnableScheduledFuture<V> future) {
|
|
this.future = future;
|
|
setExecutorThisTaskIsScheduledFor(executor);
|
|
}
|
|
|
|
public long getDelay(TimeUnit unit) {
|
|
return future.getDelay(unit);
|
|
}
|
|
|
|
public void run() {
|
|
future.run();
|
|
}
|
|
|
|
public boolean isPeriodic() {
|
|
return future.isPeriodic();
|
|
}
|
|
|
|
public boolean cancel(boolean mayInterruptIfRunning) {
|
|
return future.cancel(mayInterruptIfRunning);
|
|
}
|
|
|
|
public int compareTo(Delayed o) {
|
|
return future.compareTo(o);
|
|
}
|
|
|
|
public boolean isCancelled() {
|
|
return future.isCancelled();
|
|
}
|
|
|
|
public boolean isDone() {
|
|
return future.isDone();
|
|
}
|
|
|
|
public V get() throws InterruptedException, ExecutionException {
|
|
return callGetAndTraceAfterEachTimeout(future);
|
|
}
|
|
|
|
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
|
|
return future.get(timeout, unit);
|
|
}
|
|
}
|