Пример #1
0
  @After
  public void tearDown() throws Exception {
    for (DelayedEventHandler delayedEventHandler : delayedEventHandlers) {
      delayedEventHandler.stopWaiting();
    }

    disruptor.halt();
    executor.joinAllThreads();
  }
Пример #2
0
  private void ensureTwoEventsProcessedAccordingToDependencies(
      final CountDownLatch countDownLatch, final DelayedEventHandler... dependencies)
      throws InterruptedException {
    publishEvent();
    publishEvent();

    for (DelayedEventHandler dependency : dependencies) {
      assertThatCountDownLatchEquals(countDownLatch, 2L);
      dependency.processEvent();
      dependency.processEvent();
    }

    assertThatCountDownLatchIsZero(countDownLatch);
  }
Пример #3
0
  @Test
  public void shouldBlockProducerUntilAllEventProcessorsHaveAdvanced() throws Exception {
    final DelayedEventHandler delayedEventHandler = createDelayedEventHandler();
    disruptor.handleEventsWith(delayedEventHandler);

    final RingBuffer<TestEvent> ringBuffer = disruptor.start();

    final StubPublisher stubPublisher = new StubPublisher(ringBuffer);
    try {
      executor.execute(stubPublisher);

      assertProducerReaches(stubPublisher, 4, true);

      delayedEventHandler.processEvent();
      delayedEventHandler.processEvent();
      delayedEventHandler.processEvent();
      delayedEventHandler.processEvent();
      delayedEventHandler.processEvent();

      assertProducerReaches(stubPublisher, 5, false);
    } finally {
      stubPublisher.halt();
    }
  }