Class WorkerPool<T>

  • Type Parameters:
    T - event to be processed by a pool of workers

    public final class WorkerPool<T>
    extends Object
    WorkerPool contains a pool of WorkProcessors that will consume sequences so jobs can be farmed out across a pool of workers. Each of the WorkProcessors manage and calls a WorkHandler to process the events.
    • Method Detail

      • getWorkerSequences

        public Sequence[] getWorkerSequences()
        Get an array of Sequences representing the progress of the workers.
        Returns:
        an array of Sequences representing the progress of the workers.
      • start

        public RingBuffer<T> start​(Executor executor)
        Start the worker pool processing events in sequence.
        Parameters:
        executor - providing threads for running the workers.
        Returns:
        the RingBuffer used for the work queue.
        Throws:
        IllegalStateException - if the pool has already been started and not halted yet
      • drainAndHalt

        public void drainAndHalt()
        Wait for the RingBuffer to drain of published events then halt the workers.
      • halt

        public void halt()
        Halt all workers immediately at the end of their current cycle.
      • isRunning

        public boolean isRunning()