public abstract class OACircularQueue<TYPE> extends Object
Modifier and Type | Field and Description |
---|---|
int |
msWaitUntilNotified |
Modifier | Constructor and Description |
---|---|
protected |
OACircularQueue() |
|
OACircularQueue(Class clazz,
int queueSize) |
|
OACircularQueue(int queueSize)
Create a new circular queue.
|
Modifier and Type | Method and Description |
---|---|
int |
addMessage(TYPE msg) |
int |
addMessageToQueue(TYPE msg)
Add a new message to the queue.
|
int |
addMessageToQueue(TYPE msg,
int throttleAmount)
param bThrottle if true, then make sure that headPos is not too far ahead of readers
|
int |
addMessageToQueue(TYPE msg,
int throttleAmount,
int throttleSessionToIgnore) |
protected void |
cleanupQueue() |
int |
getAmountAvailable(long posTail) |
long |
getHeadPostion()
current position where the next message will be added.
|
TYPE |
getMessage(long posTail)
will block until a message is available.
|
TYPE |
getMessage(long posTail,
int msMaxWait)
Get next message, with a timeout
|
TYPE[] |
getMessages(int sessionId,
long posTail,
int maxReturnAmount,
int msMaxWait) |
TYPE[] |
getMessages(long posTail)
will block until at least one message is available.
|
TYPE[] |
getMessages(long posTail,
int maxReturnAmount)
will block until at least one message is available.
|
TYPE[] |
getMessages(long posTail,
int maxReturnAmount,
int msMaxWait) |
TYPE |
getMessagesAtPos(int pos)
Get message at actual position in queue
|
String |
getName() |
int |
getSize() |
void |
keepAlive(int sessionId) |
long |
registerSession(int sessionId)
This is used to let the queue know who the consumers are, so that
queue slots can be set to null once they are not needed.
|
void |
setName(String s) |
void |
setSize(int queueSize)
set the size of the array behind the circular queue
|
protected boolean |
shouldWaitOnSlowSession(int sessionId,
int msSinceLastRead)
This is call whenever a session is getting close to a queue overrun and it has not
called get for 1+ seconds.
|
void |
unregisterSession(int sessionId) |
public final int msWaitUntilNotified
public OACircularQueue(int queueSize)
queueSize
- actual size of the array that backs the queue.public OACircularQueue(Class clazz, int queueSize)
protected OACircularQueue()
public void setSize(int queueSize)
public int getSize()
public long registerSession(int sessionId)
sessionId
- identifier for the session
param maxFallBehind max amount that it can fall behind the head, else an addMessage will wait for up to 1 second.public void unregisterSession(int sessionId)
protected void cleanupQueue()
public long getHeadPostion()
public int addMessageToQueue(TYPE msg)
public int addMessage(TYPE msg)
public int addMessageToQueue(TYPE msg, int throttleAmount)
public int addMessageToQueue(TYPE msg, int throttleAmount, int throttleSessionToIgnore)
protected boolean shouldWaitOnSlowSession(int sessionId, int msSinceLastRead)
sessionId
- public TYPE getMessage(long posTail) throws Exception
Exception
public TYPE getMessage(long posTail, int msMaxWait) throws Exception
posTail
- current position to pull messages frommsMaxWait
- max number of milliseconds to waitException
public TYPE[] getMessages(long posTail) throws Exception
Exception
public TYPE[] getMessages(long posTail, int maxReturnAmount) throws Exception
Exception
public TYPE[] getMessages(long posTail, int maxReturnAmount, int msMaxWait) throws Exception
posTail
- current position to use to get next messagemaxReturnAmount
- msMaxWait
- if no messages are available, wait this amount of miliseconds for an available message.Exception
public TYPE[] getMessages(int sessionId, long posTail, int maxReturnAmount, int msMaxWait) throws Exception
Exception
public void keepAlive(int sessionId)
public TYPE getMessagesAtPos(int pos)
pos
- is actual array position, must be less then queSize, else null is returned.public void setName(String s)
public String getName()
Copyright © 1999–2019 ViaOA. All rights reserved.