Class NoCloseExecutor
- java.lang.Object
-
- org.apache.sshd.common.util.threads.NoCloseExecutor
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,java.util.concurrent.Executor,java.util.concurrent.ExecutorService,Closeable,CloseableExecutorService
public class NoCloseExecutor extends java.lang.Object implements CloseableExecutorService
Wraps anExecutorServiceas aCloseableExecutorServiceand avoids calling itsshutdownmethods when the wrapper is shut down
-
-
Field Summary
Fields Modifier and Type Field Description protected CloseFuturecloseFutureprotected java.util.concurrent.ExecutorServiceexecutor
-
Constructor Summary
Constructors Constructor Description NoCloseExecutor(java.util.concurrent.ExecutorService executor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCloseFutureListener(SshFutureListener<CloseFuture> listener)Pre-register a listener to be informed when resource is closed.booleanawaitTermination(long timeout, java.util.concurrent.TimeUnit unit)CloseFutureclose(boolean immediately)Close this resource asynchronously and return a future.voidexecute(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> TinvokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)<T> TinvokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)booleanisClosed()Returnstrueif this object has been closed.booleanisClosing()Returnstrueif theCloseable.close(boolean)method has been called.booleanisShutdown()booleanisTerminated()voidremoveCloseFutureListener(SshFutureListener<CloseFuture> listener)Remove a pre-registered close event listenervoidshutdown()java.util.List<java.lang.Runnable>shutdownNow()java.util.concurrent.Future<?>submit(java.lang.Runnable task)<T> java.util.concurrent.Future<T>submit(java.lang.Runnable task, T result)<T> java.util.concurrent.Future<T>submit(java.util.concurrent.Callable<T> task)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.util.threads.CloseableExecutorService
awaitTermination, close
-
-
-
-
Field Detail
-
executor
protected final java.util.concurrent.ExecutorService executor
-
closeFuture
protected final CloseFuture closeFuture
-
-
Method Detail
-
submit
public <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
- Specified by:
submitin interfacejava.util.concurrent.ExecutorService
-
submit
public <T> java.util.concurrent.Future<T> submit(java.lang.Runnable task, T result)- Specified by:
submitin interfacejava.util.concurrent.ExecutorService
-
submit
public java.util.concurrent.Future<?> submit(java.lang.Runnable task)
- Specified by:
submitin interfacejava.util.concurrent.ExecutorService
-
invokeAll
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- Specified by:
invokeAllin interfacejava.util.concurrent.ExecutorService- Throws:
java.lang.InterruptedException
-
invokeAll
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- Specified by:
invokeAllin interfacejava.util.concurrent.ExecutorService- Throws:
java.lang.InterruptedException
-
invokeAny
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException- Specified by:
invokeAnyin interfacejava.util.concurrent.ExecutorService- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException
-
invokeAny
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- Specified by:
invokeAnyin interfacejava.util.concurrent.ExecutorService- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutException
-
execute
public void execute(java.lang.Runnable command)
- Specified by:
executein interfacejava.util.concurrent.Executor
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfacejava.util.concurrent.ExecutorService
-
shutdownNow
public java.util.List<java.lang.Runnable> shutdownNow()
- Specified by:
shutdownNowin interfacejava.util.concurrent.ExecutorService
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdownin interfacejava.util.concurrent.ExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminatedin interfacejava.util.concurrent.ExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException- Specified by:
awaitTerminationin interfacejava.util.concurrent.ExecutorService- Throws:
java.lang.InterruptedException
-
close
public CloseFuture close(boolean immediately)
Description copied from interface:CloseableClose 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:
closein interfaceCloseable- Parameters:
immediately-trueif the resource should be shut down abruptly,falsefor a graceful close- Returns:
- a
CloseFuturerepresenting the close request
-
addCloseFutureListener
public void addCloseFutureListener(SshFutureListener<CloseFuture> listener)
Description copied from interface:CloseablePre-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:
addCloseFutureListenerin interfaceCloseable- Parameters:
listener- The notificationSshFutureListener- nevernull
-
removeCloseFutureListener
public void removeCloseFutureListener(SshFutureListener<CloseFuture> listener)
Description copied from interface:CloseableRemove a pre-registered close event listener- Specified by:
removeCloseFutureListenerin interfaceCloseable- Parameters:
listener- The registerSshFutureListener- nevernull. Ignored if not registered or resource already closed
-
isClosed
public boolean isClosed()
Description copied from interface:CloseableReturnstrueif this object has been closed.
-
isClosing
public boolean isClosing()
Description copied from interface:CloseableReturnstrueif theCloseable.close(boolean)method has been called. Note that this method will returntrueeven if thisCloseable.isClosed()returnstrue.
-
-