Package org.jenkinsci.remoting.util
Interface ListenableFuture<V>
-
- All Known Implementing Classes:
SettableFuture
public interface ListenableFuture<V> extends Future<V>
ExtendFuture
with the capability to accept completion callbacks. If the future has completed when the callback is added, the callback is triggered immediately.Inspired by
com.google.common.util.concurrent.ListenableFuture
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addListener(Runnable listener, Executor executor)
Registers a listener to be run.
-
-
-
Method Detail
-
addListener
void addListener(@NonNull Runnable listener, @NonNull Executor executor)
Registers a listener to be run. The listener will be run on the specified executor either when theFuture
's computation is complete or, if the computation is already complete, immediately. There is no guaranteed ordering of execution of listeners, but any listener added through this method is guaranteed to be called once the computation is complete. Exceptions thrown by a listener will be propagated up to the executor. Any exception thrown duringExecutor.execute(Runnable)
(e.g., aRejectedExecutionException
or an exception thrown by direct execution) will be caught and logged.- Parameters:
listener
- the listener to execute.executor
- the executor to run the listener in.
-
-