Package org.apache.curator.utils
Class CloseableExecutorService
- java.lang.Object
-
- org.apache.curator.utils.CloseableExecutorService
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
CloseableScheduledExecutorService
public class CloseableExecutorService extends java.lang.Object implements java.io.CloseableDecoration on an ExecutorService that tracks created futures and provides a method to close futures created via this class
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classCloseableExecutorService.InternalFutureTask<T>protected classCloseableExecutorService.InternalScheduledFutureTask
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.atomic.AtomicBooleanisOpen
-
Constructor Summary
Constructors Constructor Description CloseableExecutorService(java.util.concurrent.ExecutorService executorService)CloseableExecutorService(java.util.concurrent.ExecutorService executorService, boolean shutdownOnClose)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes any tasks currently in progressbooleanisShutdown()Returns true if this executor has been shut down.java.util.concurrent.Future<?>submit(java.lang.Runnable task)Submits a Runnable task for execution and returns a Future representing that task.<V> java.util.concurrent.Future<V>submit(java.util.concurrent.Callable<V> task)Submits a value-returning task for execution and returns a Future representing the pending results of the task.
-
-
-
Constructor Detail
-
CloseableExecutorService
public CloseableExecutorService(java.util.concurrent.ExecutorService executorService)
- Parameters:
executorService- the service to decorate
-
CloseableExecutorService
public CloseableExecutorService(java.util.concurrent.ExecutorService executorService, boolean shutdownOnClose)- Parameters:
executorService- the service to decorateshutdownOnClose- if true, shutdown the executor service when this is closed
-
-
Method Detail
-
isShutdown
public boolean isShutdown()
Returns true if this executor has been shut down.- Returns:
- true if this executor has been shut down
-
close
public void close()
Closes any tasks currently in progress- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
submit
public <V> java.util.concurrent.Future<V> submit(java.util.concurrent.Callable<V> task)
Submits a value-returning task for execution and returns a Future representing the pending results of the task. Upon completion, this task may be taken or polled.- Parameters:
task- the task to submit- Returns:
- a future to watch the task
-
submit
public java.util.concurrent.Future<?> submit(java.lang.Runnable task)
Submits a Runnable task for execution and returns a Future representing that task. Upon completion, this task may be taken or polled.- Parameters:
task- the task to submit- Returns:
- a future to watch the task
-
-