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<Integer,Integer> |
PARK |
protected RingBuffer<Message> |
rb |
protected Runnable |
run_function |
protected static BiConsumer<Integer,Integer> |
SPIN |
protected static BiConsumer<Integer,Integer> |
SPIN_PARK |
protected static BiConsumer<Integer,Integer> |
SPIN_YIELD |
protected static String |
THREAD_NAME |
protected BiConsumer<Integer,Integer> |
wait_strategy |
protected static BiConsumer<Integer,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,
String message) |
RingBuffer<Message> |
buf() |
protected BiConsumer<Integer,Integer> |
createWaitStrategy(String st,
BiConsumer<Integer,Integer> default_wait_strategy) |
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 String |
print(BiConsumer<Integer,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() |
String |
waitStrategy() |
RingBufferBundler |
waitStrategy(String st) |
addMessage, clearMessages, sendBundledMessages, sendMessageList, sendSingleMessage, viewChange
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getStats, resetStats
protected RingBuffer<Message> rb
protected Runner bundler_thread
protected int num_spins
protected static final String THREAD_NAME
protected BiConsumer<Integer,Integer> wait_strategy
protected int capacity
protected final Runnable run_function
protected static final BiConsumer<Integer,Integer> SPIN
protected static final BiConsumer<Integer,Integer> YIELD
protected static final BiConsumer<Integer,Integer> PARK
protected static final BiConsumer<Integer,Integer> SPIN_PARK
protected static final BiConsumer<Integer,Integer> SPIN_YIELD
public RingBufferBundler()
protected RingBufferBundler(RingBuffer<Message> rb)
public RingBufferBundler(int capacity)
public RingBuffer<Message> buf()
public Thread getThread()
public int size()
Bundler
size
in interface Bundler
size
in class BaseBundler
public int numSpins()
public RingBufferBundler numSpins(int n)
public String waitStrategy()
public RingBufferBundler waitStrategy(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 Exception
send
in interface Bundler
send
in class BaseBundler
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 Exception
Exception
protected void readMessages()
protected final int advance(int index)
protected final int index(int idx)
protected static String print(BiConsumer<Integer,Integer> wait_strategy)
protected BiConsumer<Integer,Integer> createWaitStrategy(String st, BiConsumer<Integer,Integer> default_wait_strategy)
protected static int assertPositive(int value, String message)
Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.