Ejemplo n.º 1
0
  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();
  }
Ejemplo n.º 2
0
 @Override
 public void halt() {
   workerPool.halt();
 }
Ejemplo n.º 3
0
 @Override
 public void start(final Executor executor) {
   workerPool.start(executor);
 }
Ejemplo n.º 4
0
 @Override
 public Sequence[] getSequences() {
   return workerPool.getWorkerSequences();
 }