public class RingBufferBundler extends BaseBundler
RingBuffer
to store messages. The difference to TransferQueueBundler
is that
RingBuffer uses a wait strategy (to for example spinning) before blocking. Also, the hashmap of the superclass is not
used, but the array of the RingBuffer is used directly to bundle and send messages, minimizing memory allocation.Modifier and Type | Field and Description |
---|---|
protected Runner |
bundler_thread |
protected int |
capacity |
protected int |
num_spins |
protected static BiConsumer<java.lang.Integer,java.lang.Integer> |
PARK |
protected RingBuffer<Message> |
rb |
protected java.lang.Runnable |
run_function |
protected static BiConsumer<java.lang.Integer,java.lang.Integer> |
SPIN |
protected static BiConsumer<java.lang.Integer,java.lang.Integer> |
SPIN_PARK |
protected static BiConsumer<java.lang.Integer,java.lang.Integer> |
SPIN_YIELD |
protected java.lang.Runnable |
stop_function |
protected static java.lang.String |
THREAD_NAME |
protected BiConsumer<java.lang.Integer,java.lang.Integer> |
wait_strategy |
protected static BiConsumer<java.lang.Integer,java.lang.Integer> |
YIELD |
Modifier | Constructor and Description |
---|---|
|
RingBufferBundler() |
|
RingBufferBundler(int capacity) |
protected |
RingBufferBundler(RingBuffer<Message> rb) |
Modifier and Type | Method and Description |
---|---|
protected int |
advance(int index) |
protected static int |
assertPositive(int value,
java.lang.String message) |
RingBuffer<Message> |
buf() |
protected BiConsumer<java.lang.Integer,java.lang.Integer> |
createWaitStrategy(java.lang.String st,
BiConsumer<java.lang.Integer,java.lang.Integer> default_wait_strategy) |
java.lang.Thread |
getThread() |
protected int |
index(int idx) |
void |
init(TP transport)
Called after creation of the bundler
|
protected int |
marshalMessagesToSameDestination(Address dest,
Message[] buf,
int start_index,
int end_index,
int max_bundle_size) |
int |
numSpins() |
RingBufferBundler |
numSpins(int n) |
protected static java.lang.String |
print(BiConsumer<java.lang.Integer,java.lang.Integer> wait_strategy) |
protected void |
readMessages() |
void |
send(Message msg) |
void |
sendBundledMessages(Message[] buf,
int read_index,
int available_msgs)
Read and send messages in range [read-index ..
|
int |
size()
The number of unsent messages in the bundler
|
void |
start()
Called after
Bundler.init(TP) |
void |
stop() |
java.lang.String |
waitStrategy() |
RingBufferBundler |
waitStrategy(java.lang.String st) |
addMessage, checkForSharedTransport, clearMessages, sendBundledMessages, sendMessageList, sendSingleMessage, viewChange
protected RingBuffer<Message> rb
protected Runner bundler_thread
protected int num_spins
protected static final java.lang.String THREAD_NAME
protected BiConsumer<java.lang.Integer,java.lang.Integer> wait_strategy
protected int capacity
protected final java.lang.Runnable run_function
protected final java.lang.Runnable stop_function
protected static final BiConsumer<java.lang.Integer,java.lang.Integer> SPIN
protected static final BiConsumer<java.lang.Integer,java.lang.Integer> YIELD
protected static final BiConsumer<java.lang.Integer,java.lang.Integer> PARK
protected static final BiConsumer<java.lang.Integer,java.lang.Integer> SPIN_PARK
protected static final BiConsumer<java.lang.Integer,java.lang.Integer> SPIN_YIELD
public RingBufferBundler()
protected RingBufferBundler(RingBuffer<Message> rb)
public RingBufferBundler(int capacity)
public RingBuffer<Message> buf()
public java.lang.Thread getThread()
public int size()
Bundler
size
in interface Bundler
size
in class BaseBundler
public int numSpins()
public RingBufferBundler numSpins(int n)
public java.lang.String waitStrategy()
public RingBufferBundler waitStrategy(java.lang.String st)
public void init(TP transport)
Bundler
init
in interface Bundler
init
in class BaseBundler
transport
- the transport, for further referencepublic void start()
Bundler
Bundler.init(TP)
start
in interface Bundler
start
in class BaseBundler
public void stop()
stop
in interface Bundler
stop
in class BaseBundler
public void send(Message msg) throws java.lang.Exception
send
in interface Bundler
send
in class BaseBundler
java.lang.Exception
public void sendBundledMessages(Message[] buf, int read_index, int available_msgs)
protected int marshalMessagesToSameDestination(Address dest, Message[] buf, int start_index, int end_index, int max_bundle_size) throws java.lang.Exception
java.lang.Exception
protected void readMessages()
protected final int advance(int index)
protected final int index(int idx)
protected static java.lang.String print(BiConsumer<java.lang.Integer,java.lang.Integer> wait_strategy)
protected BiConsumer<java.lang.Integer,java.lang.Integer> createWaitStrategy(java.lang.String st, BiConsumer<java.lang.Integer,java.lang.Integer> default_wait_strategy)
protected static int assertPositive(int value, java.lang.String message)
Copyright © 1998-2020 Red Hat. All Rights Reserved.