Class NoCloseExecutor
- java.lang.Object
-
- org.apache.sshd.common.util.threads.NoCloseExecutor
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,Executor
,ExecutorService
,Closeable
,CloseableExecutorService
public class NoCloseExecutor extends Object implements CloseableExecutorService
Wraps anExecutorService
as aCloseableExecutorService
and avoids calling itsshutdown
methods when the wrapper is shut down- Author:
- Apache MINA SSHD Project
-
-
Field Summary
Fields Modifier and Type Field Description protected CloseFuture
closeFuture
protected ExecutorService
executor
-
Fields inherited from interface org.apache.sshd.common.Closeable
CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT
-
-
Constructor Summary
Constructors Constructor Description NoCloseExecutor(ExecutorService executor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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()
Returnstrue
if this object has been closed.boolean
isClosing()
Returnstrue
if theCloseable.close(boolean)
method has been called.boolean
isShutdown()
boolean
isTerminated()
void
removeCloseFutureListener(SshFutureListener<CloseFuture> listener)
Remove a pre-registered close event listenervoid
shutdown()
List<Runnable>
shutdownNow()
Future<?>
submit(Runnable task)
<T> Future<T>
submit(Runnable task, T result)
<T> Future<T>
submit(Callable<T> task)
-
-
-
Field Detail
-
executor
protected final ExecutorService executor
-
closeFuture
protected final CloseFuture closeFuture
-
-
Constructor Detail
-
NoCloseExecutor
public NoCloseExecutor(ExecutorService executor)
-
-
Method Detail
-
submit
public <T> Future<T> submit(Callable<T> task)
- Specified by:
submit
in interfaceExecutorService
-
submit
public <T> Future<T> submit(Runnable task, T result)
- Specified by:
submit
in interfaceExecutorService
-
submit
public Future<?> submit(Runnable task)
- Specified by:
submit
in interfaceExecutorService
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
- Specified by:
invokeAll
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
- Specified by:
invokeAll
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
- Specified by:
invokeAny
in interfaceExecutorService
- Throws:
InterruptedException
ExecutionException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
invokeAny
in interfaceExecutorService
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfaceExecutorService
-
shutdownNow
public List<Runnable> shutdownNow()
- Specified by:
shutdownNow
in interfaceExecutorService
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdown
in interfaceExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminated
in interfaceExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
- Specified by:
awaitTermination
in interfaceExecutorService
- Throws:
InterruptedException
-
close
public CloseFuture close(boolean immediately)
Description copied from interface:Closeable
Close this resource asynchronously and return a future. Resources support two closing modes: a graceful mode which will cleanly close the resource and an immediate mode which will close the resources abruptly.- Specified by:
close
in interfaceCloseable
- Parameters:
immediately
-true
if the resource should be shut down abruptly,false
for a graceful close- Returns:
- a
CloseFuture
representing the close request
-
addCloseFutureListener
public void addCloseFutureListener(SshFutureListener<CloseFuture> listener)
Description copied from interface:Closeable
Pre-register a listener to be informed when resource is closed. If resource is already closed, the listener will be invoked immediately and not registered for future notification- Specified by:
addCloseFutureListener
in interfaceCloseable
- Parameters:
listener
- The notificationSshFutureListener
- nevernull
-
removeCloseFutureListener
public void removeCloseFutureListener(SshFutureListener<CloseFuture> listener)
Description copied from interface:Closeable
Remove a pre-registered close event listener- Specified by:
removeCloseFutureListener
in interfaceCloseable
- Parameters:
listener
- The registerSshFutureListener
- nevernull
. Ignored if not registered or resource already closed
-
isClosed
public boolean isClosed()
Description copied from interface:Closeable
Returnstrue
if this object has been closed.
-
isClosing
public boolean isClosing()
Description copied from interface:Closeable
Returnstrue
if theCloseable.close(boolean)
method has been called. Note that this method will returntrue
even if thisCloseable.isClosed()
returnstrue
.
-
-