コード例 #1
0
  private static void roundTripMessages(
      final FragmentHandler fragmentHandler,
      final Publication pingPublication,
      final Subscription pongSubscription,
      final int numMessages) {
    final IdleStrategy idleStrategy = new BusySpinIdleStrategy();

    for (int i = 0; i < numMessages; i++) {
      do {
        ATOMIC_BUFFER.putLong(0, System.nanoTime());
      } while (pingPublication.offer(ATOMIC_BUFFER, 0, MESSAGE_LENGTH) < 0L);

      idleStrategy.reset();
      while (pongSubscription.poll(fragmentHandler, FRAGMENT_COUNT_LIMIT) <= 0) {
        idleStrategy.idle();
      }
    }
  }
コード例 #2
0
 private static void availablePongImageHandler(final Image image) {
   final Subscription subscription = image.subscription();
   if (PONG_STREAM_ID == subscription.streamId() && PONG_CHANNEL.equals(subscription.channel())) {
     PONG_IMAGE_LATCH.countDown();
   }
 }