public class NoCloseExecutor extends 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 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, wait
close, close, getMaxCloseWaitTime, isOpen
protected final ExecutorService executor
protected final CloseFuture closeFuture
public NoCloseExecutor(ExecutorService executor)
public <T> Future<T> submit(Callable<T> task)
submit
in interface ExecutorService
public <T> Future<T> submit(Runnable task, T result)
submit
in interface ExecutorService
public Future<?> submit(Runnable task)
submit
in interface ExecutorService
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
invokeAll
in interface ExecutorService
InterruptedException
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
invokeAll
in interface ExecutorService
InterruptedException
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
invokeAny
in interface ExecutorService
InterruptedException
ExecutionException
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
invokeAny
in interface ExecutorService
InterruptedException
ExecutionException
TimeoutException
public void shutdown()
shutdown
in interface ExecutorService
public List<Runnable> shutdownNow()
shutdownNow
in interface ExecutorService
public boolean isShutdown()
isShutdown
in interface ExecutorService
public boolean isTerminated()
isTerminated
in interface ExecutorService
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
awaitTermination
in interface ExecutorService
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 closingCopyright © 2008–2022 The Apache Software Foundation. All rights reserved.