public class NoCloseExecutor extends java.lang.Object implements CloseableExecutorService
ExecutorService
as a CloseableExecutorService
and avoids calling its shutdown
methods when the wrapper is shut downModifier 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, wait
awaitTermination
close, close, getMaxCloseWaitTime, isOpen
protected 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.ExecutorService
public <T> java.util.concurrent.Future<T> submit(java.lang.Runnable task, T result)
submit
in interface java.util.concurrent.ExecutorService
public java.util.concurrent.Future<?> submit(java.lang.Runnable task)
submit
in interface java.util.concurrent.ExecutorService
public <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.ExecutorService
java.lang.InterruptedException
public <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.ExecutorService
java.lang.InterruptedException
public <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.ExecutorService
java.lang.InterruptedException
java.util.concurrent.ExecutionException
public <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.ExecutorService
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public void execute(java.lang.Runnable command)
execute
in interface java.util.concurrent.Executor
public void shutdown()
shutdown
in interface java.util.concurrent.ExecutorService
public java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow
in interface java.util.concurrent.ExecutorService
public boolean isShutdown()
isShutdown
in interface java.util.concurrent.ExecutorService
public boolean isTerminated()
isTerminated
in interface java.util.concurrent.ExecutorService
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
awaitTermination
in interface java.util.concurrent.ExecutorService
java.lang.InterruptedException
public CloseFuture close(boolean immediately)
Closeable
immediately
- true
if the resource should be shut down abruptly, false
for a
graceful closeCloseFuture
representing the close requestpublic void addCloseFutureListener(SshFutureListener<CloseFuture> listener)
Closeable
listener
- The notification SshFutureListener
- never null
public void removeCloseFutureListener(SshFutureListener<CloseFuture> listener)
Closeable
listener
- The register SshFutureListener
- never null
. Ignored if not registered or
resource already closedpublic boolean isClosed()
Closeable
true
if this object has been closed.true
if closingpublic boolean isClosing()
Closeable
true
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