Class BroadcastTransmitter

java.lang.Object
org.agrona.concurrent.broadcast.BroadcastTransmitter

public class BroadcastTransmitter extends Object
Transmit messages via an underlying broadcast buffer to zero or more BroadcastReceivers.

Note: This class is not threadsafe. Only one transmitter is allowed per broadcast buffer.

  • Field Details

    • buffer

      private final AtomicBuffer buffer
    • capacity

      private final int capacity
    • maxMsgLength

      private final int maxMsgLength
    • tailIntentCountIndex

      private final int tailIntentCountIndex
    • tailCounterIndex

      private final int tailCounterIndex
    • latestCounterIndex

      private final int latestCounterIndex
  • Constructor Details

  • Method Details

    • capacity

      public int capacity()
      Get the capacity of the underlying broadcast buffer.
      Returns:
      the capacity of the underlying broadcast buffer.
    • maxMsgLength

      public int maxMsgLength()
      Get the maximum message length that can be transmitted for a buffer.
      Returns:
      the maximum message length that can be transmitted for a buffer.
    • transmit

      public void transmit(int msgTypeId, DirectBuffer srcBuffer, int srcIndex, int length)
      Transmit a message to BroadcastReceivers via the broadcast buffer.
      Parameters:
      msgTypeId - type of the message to be transmitted.
      srcBuffer - containing the encoded message to be transmitted.
      srcIndex - srcIndex in the source buffer at which the encoded message begins.
      length - in bytes of the encoded message.
      Throws:
      IllegalArgumentException - of the msgTypeId is not valid, or if the message length is greater than maxMsgLength().
    • signalTailIntent

      private void signalTailIntent(AtomicBuffer buffer, long newTail)
    • insertPaddingRecord

      private static void insertPaddingRecord(AtomicBuffer buffer, int recordOffset, int length)
    • checkMessageLength

      private void checkMessageLength(int length)