public void engage() { // starts WorkerPool workers in separate thread(s) RingBuffer<DemoEvent> ringBuf = workerPool.start(execService); // publish lots of events for (int i = 0; i < 5 * NUM_WORKERS; i++) { long seq = ringBuf.next(); ringBuf.get(seq).setProcessId(i); ringBuf.publish(seq); // try it with and without the sleep // try { Thread.sleep(33); } catch (Exception e) { } } // wait until all published events are processed, then stop the workers workerPool.drainAndHalt(); }
@Override public void halt() { workerPool.halt(); }
@Override public void start(final Executor executor) { workerPool.start(executor); }
@Override public Sequence[] getSequences() { return workerPool.getWorkerSequences(); }