|
copyright The Portico Project 2008. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.portico.lrc.LRCQueue
public class LRCQueue
This class holds callback messages for the LRC
. It also ensures the various required
semantics relating to the status of the messages (TSO/RO) and the current status of the federate.
For example, if a federate is constrained, the queue will appear empty of TSO messages until the
current federate time has advanced such that those messages can be released.
Nested Class Summary | |
---|---|
private class |
LRCQueue.Sorter
Comparator used for sorting TSO callback messages such that the callback queue remains ordered. |
Field Summary | |
---|---|
private boolean |
async
|
private Condition |
condition
|
private boolean |
constrained
|
private Lock |
lock
|
private org.apache.log4j.Logger |
logger
|
private LRC |
lrc
|
private LRCState |
lrcState
|
private BlockingQueue<FED_CallbackMessage> |
roQueue
|
private PriorityBlockingQueue<FED_CallbackMessage> |
tsoQueue
|
Constructor Summary | |
---|---|
LRCQueue(LRC lrc)
Creates a new queue and associate it with the given LRC . |
Method Summary | |
---|---|
boolean |
isEmpty()
|
boolean |
offer(FED_CallbackMessage message)
Place the message on the queue. |
FED_CallbackMessage |
peekTSO()
This method will return the callback message at the head of the TSO queue, but it WILL NOT REMOVE IT. |
FED_CallbackMessage |
poll()
Fetch the next available message from the queue. |
FED_CallbackMessage |
poll(long timeoutNanos)
This method is the same as poll() except that if there are no messages available,
it will block until there are (or until the timeout value has been reached). |
private FED_CallbackMessage |
pollForNonMessage()
All this applies to RO messages only The HLA specification says that if a federate: a) is constrained and b) does NOT have asynchronous delivery enabled and c) isn't in the middle of a time advance, then RO "messages" cannot be released to it. |
private void |
priorityMessage(FED_CallbackMessage message)
Process a priority message. |
protected void |
setAsync(boolean async)
Enable or Disable asynchronous delivery. |
protected void |
setConstrained(boolean constrained)
Informs the queue of an update to the constrained status of the federate. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private LRC lrc
private LRCState lrcState
private BlockingQueue<FED_CallbackMessage> roQueue
private PriorityBlockingQueue<FED_CallbackMessage> tsoQueue
private org.apache.log4j.Logger logger
private boolean constrained
private boolean async
private Lock lock
private Condition condition
Constructor Detail |
---|
public LRCQueue(LRC lrc)
LRC
.
Method Detail |
---|
public boolean offer(FED_CallbackMessage message)
true
if the message was successfully added to the queue,
false
otherwise.private void priorityMessage(FED_CallbackMessage message)
public FED_CallbackMessage poll()
private FED_CallbackMessage pollForNonMessage()
public FED_CallbackMessage poll(long timeoutNanos) throws InterruptedException
poll()
except that if there are no messages available,
it will block until there are (or until the timeout value has been reached). If the blocking
thread is interrupted while waiting, an InterruptedException is thrown.
InterruptedException
public FED_CallbackMessage peekTSO()
protected void setConstrained(boolean constrained)
PorticoConstants.NULL_TIME
(thus making them RO)
This is part of a fix for issue PORT-103. Given that this method is synchronized, there
will be no chance for a poll()
to occur while there are still TSO messages
in the queue if we have become unconstrained.
protected void setAsync(boolean async)
LRCState
. It is only mirrored here for efficiency sake. If asynchronous
delivery is DISABLED, receive-order messages will only be released when the federate is in
the time advancing state. NOTE, this is only a consideration if the federate is
time constrained. If the federate is not time constrained (or it is, and async delivery is
enabled), receive-order messages will be released whenever they are available.
public boolean isEmpty()
|
copyright The Portico Project 2008. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |