public class BroadcastReceiver
extends java.lang.Object
BroadcastTransmitter
via an underlying buffer. Receivers can join
a transmission stream at any point by consuming the latest message at the point of joining and forward.
If a Receiver cannot keep up with the transmission stream then loss will be experienced. Loss is not an error condition.
Note: Each Receiver is not threadsafe but there can be zero or many receivers to a transmission stream.
Constructor and Description |
---|
BroadcastReceiver(AtomicBuffer buffer)
Construct a new broadcast receiver based on an underlying
AtomicBuffer . |
Modifier and Type | Method and Description |
---|---|
MutableDirectBuffer |
buffer()
The underlying buffer containing the broadcast message stream.
|
int |
capacity()
Get the capacity of the underlying broadcast buffer.
|
long |
lappedCount()
Get the number of times the transmitter has lapped this receiver around the buffer.
|
int |
length()
The length of the next message in the transmission stream.
|
int |
offset()
The offset for the beginning of the next message in the transmission stream.
|
boolean |
receiveNext()
Non-blocking receive of next message from the transmission stream.
|
int |
typeId()
Type of the message received.
|
boolean |
validate()
Validate that the current received record is still valid and has not been overwritten.
|
public BroadcastReceiver(AtomicBuffer buffer)
AtomicBuffer
.
The underlying buffer must a power of 2 in size plus sufficient space
for the BroadcastBufferDescriptor.TRAILER_LENGTH
.buffer
- via which messages will be exchanged.java.lang.IllegalStateException
- if the buffer capacity is not a power of 2
plus BroadcastBufferDescriptor.TRAILER_LENGTH
in capacity.public int capacity()
public long lappedCount()
Note: This method is threadsafe for calling from an external monitoring thread.
public int typeId()
public int offset()
public int length()
public MutableDirectBuffer buffer()
public boolean receiveNext()
If loss has occurred then lappedCount()
will be incremented.
public boolean validate()
If the receiver is not consuming messages fast enough to keep up with the transmitter then loss can be experienced resulting in messages being overwritten thus making them no longer valid.
Copyright © 2014-2018 Real Logic Ltd. All Rights Reserved.