Package org.agrona.concurrent.broadcast
Class BroadcastTransmitter
java.lang.Object
org.agrona.concurrent.broadcast.BroadcastTransmitter
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.
-
Constructor Summary
ConstructorsConstructorDescriptionBroadcastTransmitter(AtomicBuffer buffer) Construct a new broadcast transmitter based on an underlyingAtomicBuffer. -
Method Summary
Modifier and TypeMethodDescriptionintcapacity()Get the capacity of the underlying broadcast buffer.intGet the maximum message length that can be transmitted for a buffer.voidtransmit(int msgTypeId, DirectBuffer srcBuffer, int srcIndex, int length) Transmit a message toBroadcastReceivers via the broadcast buffer.
-
Constructor Details
-
BroadcastTransmitter
Construct a new broadcast transmitter based on an underlyingAtomicBuffer. The underlying buffer must a power of 2 in size plus sufficient space for theBroadcastBufferDescriptor.TRAILER_LENGTH.- Parameters:
buffer- via which messages will be exchanged.- Throws:
IllegalStateException- if the buffer capacity is not a power of 2 plusBroadcastBufferDescriptor.TRAILER_LENGTHin capacity.
-
-
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
Transmit a message toBroadcastReceivers 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 thanmaxMsgLength().
-