|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.lmax.disruptor.WorkerPool<T>
T - event to be processed by a pool of workerspublic final class WorkerPool<T>
A pool of WorkProcessors that will consume sequences so jobs can be farmed out across a pool of workers
which are implemented the WorkHandler interface.
| Constructor Summary | |
|---|---|
WorkerPool(EventFactory<T> eventFactory,
ClaimStrategy claimStrategy,
WaitStrategy waitStrategy,
ExceptionHandler exceptionHandler,
WorkHandler<T>... workHandlers)
Construct a work pool with an internal RingBuffer for convenience. |
|
WorkerPool(RingBuffer<T> ringBuffer,
SequenceBarrier sequenceBarrier,
ExceptionHandler exceptionHandler,
WorkHandler<T>... workHandlers)
Create a worker pool to enable an array of WorkHandlers to consume published sequences. |
|
| Method Summary | |
|---|---|
void |
drainAndHalt()
Wait for the RingBuffer to drain of published events then halt the workers. |
Sequence[] |
getWorkerSequences()
Get an array of Sequences representing the progress of the workers. |
void |
halt()
Halt all workers immediately at then end of their current cycle. |
RingBuffer<T> |
start(java.util.concurrent.Executor executor)
Start the worker pool processing events in sequence. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WorkerPool(RingBuffer<T> ringBuffer,
SequenceBarrier sequenceBarrier,
ExceptionHandler exceptionHandler,
WorkHandler<T>... workHandlers)
WorkHandlers to consume published sequences.
This option requires a pre-configured RingBuffer which must have Sequencer.setGatingSequences(Sequence...)
called before the work pool is started.
ringBuffer - of events to be consumed.sequenceBarrier - on which the workers will depend.exceptionHandler - to callback when an error occurs which is not handled by the WorkHandlers.workHandlers - to distribute the work load across.
public WorkerPool(EventFactory<T> eventFactory,
ClaimStrategy claimStrategy,
WaitStrategy waitStrategy,
ExceptionHandler exceptionHandler,
WorkHandler<T>... workHandlers)
RingBuffer for convenience.
This option does not require Sequencer.setGatingSequences(Sequence...) to be called before the work pool is started.
eventFactory - for filling the RingBufferclaimStrategy - for the RingBufferwaitStrategy - for the RingBufferexceptionHandler - to callback when an error occurs which is not handled by the WorkHandlers.workHandlers - to distribute the work load across.| Method Detail |
|---|
public Sequence[] getWorkerSequences()
Sequences representing the progress of the workers.
Sequences representing the progress of the workers.public RingBuffer<T> start(java.util.concurrent.Executor executor)
executor - providing threads for running the workers.
RingBuffer used for the work queue.
java.lang.IllegalStateException - is the pool has already been started and not halted yetpublic void drainAndHalt()
RingBuffer to drain of published events then halt the workers.
public void halt()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||