public class NoCloseExecutor extends java.lang.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 java.util.concurrent.ExecutorService |
executor |
CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT| Constructor and Description |
|---|
NoCloseExecutor(java.util.concurrent.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,
java.util.concurrent.TimeUnit unit) |
CloseFuture |
close(boolean immediately)
Close this resource asynchronously and return a future.
|
void |
execute(java.lang.Runnable command) |
<T> java.util.List<java.util.concurrent.Future<T>> |
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) |
<T> java.util.List<java.util.concurrent.Future<T>> |
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit) |
<T> T |
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) |
<T> T |
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.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() |
java.util.List<java.lang.Runnable> |
shutdownNow() |
<T> java.util.concurrent.Future<T> |
submit(java.util.concurrent.Callable<T> task) |
java.util.concurrent.Future<?> |
submit(java.lang.Runnable task) |
<T> java.util.concurrent.Future<T> |
submit(java.lang.Runnable task,
T result) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitawaitTerminationclose, close, getMaxCloseWaitTime, isOpenprotected final java.util.concurrent.ExecutorService executor
protected final CloseFuture closeFuture
public NoCloseExecutor(java.util.concurrent.ExecutorService executor)
public <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
submit in interface java.util.concurrent.ExecutorServicepublic <T> java.util.concurrent.Future<T> submit(java.lang.Runnable task,
T result)
submit in interface java.util.concurrent.ExecutorServicepublic java.util.concurrent.Future<?> submit(java.lang.Runnable task)
submit in interface java.util.concurrent.ExecutorServicepublic <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
throws java.lang.InterruptedException
invokeAll in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionpublic <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
invokeAll in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionpublic <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException
invokeAny in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
java.util.concurrent.TimeoutException
invokeAny in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutExceptionpublic void execute(java.lang.Runnable command)
execute in interface java.util.concurrent.Executorpublic void shutdown()
shutdown in interface java.util.concurrent.ExecutorServicepublic java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow in interface java.util.concurrent.ExecutorServicepublic boolean isShutdown()
isShutdown in interface java.util.concurrent.ExecutorServicepublic boolean isTerminated()
isTerminated in interface java.util.concurrent.ExecutorServicepublic boolean awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
awaitTermination in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionpublic 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 closing