Package org.agrona.concurrent.broadcast
Class CopyBroadcastReceiver
java.lang.Object
org.agrona.concurrent.broadcast.CopyBroadcastReceiver
Receiver that copies messages which have been broadcast to enable a simpler API for the client.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BroadcastReceiver
static final int
Default length for the scratch buffer for copying messages into.private final MutableDirectBuffer
-
Constructor Summary
ConstructorsConstructorDescriptionCopyBroadcastReceiver
(BroadcastReceiver receiver) Wrap aBroadcastReceiver
to simplify the API for receiving messages.CopyBroadcastReceiver
(BroadcastReceiver receiver, int scratchBufferLength) Wrap aBroadcastReceiver
to simplify the API for receiving messages.CopyBroadcastReceiver
(BroadcastReceiver receiver, MutableDirectBuffer scratchBuffer) Wrap aBroadcastReceiver
to simplify the API for receiving messages. -
Method Summary
Modifier and TypeMethodDescriptionGet the underlyingBroadcastReceiver
which this is wrapping and copying out of.int
receive
(MessageHandler handler) Receive one message from the broadcast buffer.
-
Field Details
-
SCRATCH_BUFFER_LENGTH
public static final int SCRATCH_BUFFER_LENGTHDefault length for the scratch buffer for copying messages into.- See Also:
-
receiver
-
scratchBuffer
-
-
Constructor Details
-
CopyBroadcastReceiver
Wrap aBroadcastReceiver
to simplify the API for receiving messages.- Parameters:
receiver
- to be wrapped.scratchBuffer
- to be used for copying receive buffers.
-
CopyBroadcastReceiver
Wrap aBroadcastReceiver
to simplify the API for receiving messages.- Parameters:
receiver
- to be wrapped.scratchBufferLength
- is the maximum length of a message to be copied when receiving.
-
CopyBroadcastReceiver
Wrap aBroadcastReceiver
to simplify the API for receiving messages.- Parameters:
receiver
- to be wrapped.
-
-
Method Details
-
broadcastReceiver
Get the underlyingBroadcastReceiver
which this is wrapping and copying out of.- Returns:
- the underlying
BroadcastReceiver
which this is wrapping and copying out of.
-
receive
Receive one message from the broadcast buffer.- Parameters:
handler
- to be called for each message received.- Returns:
- the number of messages that have been received.
-