Modifier and Type | Class and Description |
---|---|
private static class |
SynchronousExecutors.Distributor |
private static class |
SynchronousExecutors.QueueWrapper<T> |
private static class |
SynchronousExecutors.SerialExecutor<T> |
private static class |
SynchronousExecutors.Task<T> |
Modifier and Type | Field and Description |
---|---|
private SynchronousExecutors.Distributor |
distributor |
private java.util.concurrent.locks.Lock |
distributorLock |
private Thread |
distributorThread |
private java.util.concurrent.atomic.AtomicBoolean |
distributorWaiting |
private static Logger |
logger |
private java.util.concurrent.ScheduledExecutorService |
pool |
private List<Queue<java.util.concurrent.Callable>> |
queues |
private java.util.concurrent.locks.Condition |
workToDo |
Constructor and Description |
---|
SynchronousExecutors(java.util.concurrent.ScheduledExecutorService pool) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
addQueue(Queue<java.util.concurrent.Callable> queue) |
<T> java.util.concurrent.ExecutorService |
newSerialExecutor(java.util.concurrent.BlockingQueue<java.util.concurrent.Callable<T>> queue)
The ExecutorService returned, supports a subset of ExecutorService
methods, the intent of this executor is to serialize the execution
of tasks, it is up to the BlockingQueue or caller to ensure order, only
one task will execute at a time, that task will be retried if it fails,
using a back off strategy of 1, 5 and 10 seconds, followed by 1, 1 and 5
minutes thereafter forever, no other task will execute until the task
at the head of the queue is completed successfully.
|
(package private) boolean |
removeQueue(Object queue) |
void |
shutdown() |
void |
start()
Called after construction, this method enables objects to delay
starting threads or exporting until after construction is complete,
to allow safe publication of the service in accordance with the JMM.
|
private static final Logger logger
private final java.util.concurrent.locks.Lock distributorLock
private final java.util.concurrent.locks.Condition workToDo
private final List<Queue<java.util.concurrent.Callable>> queues
private final SynchronousExecutors.Distributor distributor
private final Thread distributorThread
private final java.util.concurrent.ScheduledExecutorService pool
private final java.util.concurrent.atomic.AtomicBoolean distributorWaiting
public SynchronousExecutors(java.util.concurrent.ScheduledExecutorService pool)
void addQueue(Queue<java.util.concurrent.Callable> queue)
boolean removeQueue(Object queue)
public void start() throws Exception
Startable
In addition to starting threads after construction, it also allows objects to avoid throwing an exception during construction to avoid finalizer attacks.
The implementation is required to ensure start() is idempotent (only executed once, additional invocations must return immediately).
public void shutdown()
public <T> java.util.concurrent.ExecutorService newSerialExecutor(java.util.concurrent.BlockingQueue<java.util.concurrent.Callable<T>> queue)
T
- queue
- Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.