public class ConstrainedExecutorService
extends java.util.concurrent.AbstractExecutorService
ExecutorService that delegates to an existing Executor
but constrains the number of concurrently executing tasks to a pre-configured value.
Copy of ConstrainedExecutorService from com.facebook.fresco:fresco:0.8.1.| Constructor and Description |
|---|
ConstrainedExecutorService(java.lang.String name,
int maxConcurrency,
java.util.concurrent.Executor executor,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue)
Creates a new
ConstrainedExecutorService. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit) |
void |
execute(java.lang.Runnable runnable)
Submit a task to be executed in the future.
|
boolean |
isIdle()
Determine whether or not the queue is idle.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
static ConstrainedExecutorService |
newConstrainedExecutor(java.lang.String name,
int maxConcurrency,
int queueSize,
java.util.concurrent.Executor executor)
Factory method to create a new
ConstrainedExecutorService with an unbounded
LinkedBlockingQueue queue. |
void |
shutdown() |
java.util.List<java.lang.Runnable> |
shutdownNow() |
public ConstrainedExecutorService(java.lang.String name,
int maxConcurrency,
java.util.concurrent.Executor executor,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue)
ConstrainedExecutorService.name - Friendly name to identify the executor in logging and reporting.maxConcurrency - Maximum number of tasks to execute in parallel on the delegate executor.executor - Delegate executor for actually running tasks.workQueue - Queue to hold Runnables for eventual execution.public static ConstrainedExecutorService newConstrainedExecutor(java.lang.String name, int maxConcurrency, int queueSize, java.util.concurrent.Executor executor)
ConstrainedExecutorService with an unbounded
LinkedBlockingQueue queue.name - Friendly name to identify the executor in logging and reporting.maxConcurrency - Maximum number of tasks to execute in parallel on the delegate executor.queueSize - Number of items that can be queued before new submissions are rejected.executor - Delegate executor for actually running tasks.ConstrainedExecutorService instance.public boolean isIdle()
public void execute(java.lang.Runnable runnable)
runnable - The task to be executed.public void shutdown()
public java.util.List<java.lang.Runnable> shutdownNow()
public boolean isShutdown()
public boolean isTerminated()
public boolean awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
java.lang.InterruptedException