use of com.lmax.disruptor.WorkHandler in project opennms by OpenNMS.
the class NewtsWriter method setUpWorkerPool.
private void setUpWorkerPool() {
// Executor that will be used to construct new threads for consumers
final ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("NewtsWriter-Consumer-%d").build();
final Executor executor = Executors.newCachedThreadPool(namedThreadFactory);
@SuppressWarnings("unchecked") final WorkHandler<SampleBatchEvent>[] handlers = new WorkHandler[m_numWriterThreads];
for (int i = 0; i < m_numWriterThreads; i++) {
handlers[i] = this;
}
m_ringBuffer = RingBuffer.createMultiProducer(SampleBatchEvent::new, m_ringBufferSize);
m_workerPool = new WorkerPool<SampleBatchEvent>(m_ringBuffer, m_ringBuffer.newBarrier(), new FatalExceptionHandler(), handlers);
m_ringBuffer.addGatingSequences(m_workerPool.getWorkerSequences());
m_workerPool.start(executor);
}
Aggregations