Ejemplo n.º 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();
      }
    }
  }
Ejemplo n.º 2
0
 @Override
 public void onMessage(int msgTypeId, MutableDirectBuffer buffer, int index, int length) {
   while (!inputRingBuffer.write(msgTypeId, buffer, index, length)) {
     idleStrategy.idle(0);
   }
 }