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
BroadcastReceiver
s.
Note: This class is not threadsafe. Only one transmitter is allowed per broadcast buffer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicBuffer
private final int
private final int
private final int
private final int
private final int
-
Constructor Summary
ConstructorsConstructorDescriptionBroadcastTransmitter
(AtomicBuffer buffer) Construct a new broadcast transmitter based on an underlyingAtomicBuffer
. -
Method Summary
Modifier and TypeMethodDescriptionint
capacity()
Get the capacity of the underlying broadcast buffer.private void
checkMessageLength
(int length) private static void
insertPaddingRecord
(AtomicBuffer buffer, int recordOffset, int length) int
Get the maximum message length that can be transmitted for a buffer.private void
signalTailIntent
(AtomicBuffer buffer, long newTail) void
transmit
(int msgTypeId, DirectBuffer srcBuffer, int srcIndex, int length) Transmit a message toBroadcastReceiver
s via the broadcast buffer.
-
Field Details
-
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
-
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_LENGTH
in 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 toBroadcastReceiver
s 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()
.
-
signalTailIntent
-
insertPaddingRecord
-
checkMessageLength
private void checkMessageLength(int length)
-