public class NoCloseExecutor extends Object implements CloseableExecutorService
ExecutorService as a CloseableExecutorService and avoids calling its shutdown
methods when the wrapper is shut down| Modifier and Type | Field and Description |
|---|---|
protected CloseFuture |
closeFuture |
protected ExecutorService |
executor |
CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT| Constructor and Description |
|---|
NoCloseExecutor(ExecutorService executor) |
| Modifier and Type | Method and Description |
|---|---|
void |
addCloseFutureListener(SshFutureListener<CloseFuture> listener)
Pre-register a listener to be informed when resource is closed.
|
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
CloseFuture |
close(boolean immediately)
Close this resource asynchronously and return a future.
|
void |
execute(Runnable command) |
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks) |
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit) |
<T> T |
invokeAny(Collection<? extends Callable<T>> tasks) |
<T> T |
invokeAny(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit) |
boolean |
isClosed()
Returns
true if this object has been closed. |
boolean |
isClosing()
Returns
true if the Closeable.close(boolean) method has been called. |
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
removeCloseFutureListener(SshFutureListener<CloseFuture> listener)
Remove a pre-registered close event listener
|
void |
shutdown() |
List<Runnable> |
shutdownNow() |
<T> Future<T> |
submit(Callable<T> task) |
Future<?> |
submit(Runnable task) |
<T> Future<T> |
submit(Runnable task,
T result) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitawaitTerminationclose, close, getMaxCloseWaitTime, isOpenprotected final ExecutorService executor
protected final CloseFuture closeFuture
public NoCloseExecutor(ExecutorService executor)
public <T> Future<T> submit(Callable<T> task)
submit in interface ExecutorServicepublic <T> Future<T> submit(Runnable task, T result)
submit in interface ExecutorServicepublic Future<?> submit(Runnable task)
submit in interface ExecutorServicepublic <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedExceptionpublic <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedExceptionpublic <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
invokeAny in interface ExecutorServiceInterruptedExceptionExecutionExceptionpublic <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
invokeAny in interface ExecutorServiceInterruptedExceptionExecutionExceptionTimeoutExceptionpublic void shutdown()
shutdown in interface ExecutorServicepublic List<Runnable> shutdownNow()
shutdownNow in interface ExecutorServicepublic boolean isShutdown()
isShutdown in interface ExecutorServicepublic boolean isTerminated()
isTerminated in interface ExecutorServicepublic boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface ExecutorServiceInterruptedExceptionpublic CloseFuture close(boolean immediately)
Closeableimmediately - true if the resource should be shut down abruptly, false for a
graceful closeCloseFuture representing the close requestpublic void addCloseFutureListener(SshFutureListener<CloseFuture> listener)
Closeablelistener - The notification SshFutureListener - never nullpublic void removeCloseFutureListener(SshFutureListener<CloseFuture> listener)
Closeablelistener - The register SshFutureListener - never null. Ignored if not registered or
resource already closedpublic boolean isClosed()
Closeabletrue if this object has been closed.true if closingpublic boolean isClosing()
Closeabletrue if the Closeable.close(boolean) method has been called. Note that this method will
return true even if this Closeable.isClosed() returns true.true if closingCopyright © 2018–2020 The Apache Software Foundation. All rights reserved.