Example #1
0
 private void consumeBatchToCursor(long cursor, EventHandler<Object> handler) {
   for (long curr = _consumer.get() + 1; curr <= cursor; curr++) {
     try {
       MutableObject mo = _buffer.get(curr);
       Object o = mo.o;
       mo.setObject(null);
       if (o == FLUSH_CACHE) {
         Object c = null;
         while (true) {
           c = _cache.poll();
           if (c == null) break;
           else handler.onEvent(c, curr, true);
         }
       } else if (o == INTERRUPT) {
         throw new InterruptedException("Disruptor processing interrupted");
       } else {
         handler.onEvent(o, curr, curr == cursor);
       }
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
   }
   // TODO: only set this if the consumer cursor has changed?
   _consumer.set(cursor);
 }
 public SequenceBarrier getBarrierFor(EventHandler<T> paramEventHandler) {
   paramEventHandler = getEventProcessorInfo(paramEventHandler);
   if (paramEventHandler != null) return paramEventHandler.getBarrier();
   return null;
 }