@Test public void shouldSetSequenceForHandlerIfAddedAfterPublish() throws Exception { RingBuffer<TestEvent> rb = disruptor.getRingBuffer(); EventHandler<TestEvent> b1 = new SleepingEventHandler(); EventHandler<TestEvent> b2 = new SleepingEventHandler(); EventHandler<TestEvent> b3 = new SleepingEventHandler(); rb.publish(rb.next()); rb.publish(rb.next()); rb.publish(rb.next()); rb.publish(rb.next()); rb.publish(rb.next()); rb.publish(rb.next()); disruptor.handleEventsWith(b1, b2, b3); assertThat(disruptor.getSequenceValueFor(b1), is(5L)); assertThat(disruptor.getSequenceValueFor(b2), is(5L)); assertThat(disruptor.getSequenceValueFor(b3), is(5L)); }
private boolean isEventProcessed(long sequence) { return disruptor.getSequenceValueFor(reportingEventHandler) >= sequence; }