|
Boeing Simulation 3.1 API Specification | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--util.ConsumerQueue
This class is to be used as a way for multiple Thread
objects to request access to ReturnValues coming in across a ConsumerChannel. Each return value is associated with a unique ID
number. Accessing threads may call a dequeue passing in the ID
value which will cause that thread to block until a ReturnValue matching that ID is read in off the channel.
Furthermore, non ReturnValue objects are enqueued in the
ordinaryObject queue which can be accessed by the dequeue
method that does not take in any parameters. This is also a
blocking method but this does not mean that it blocks at the same
time as the ReturnValue dequeue will.
MethodRequest,
ReturnValue| Field Summary | |
protected connect.ConsumerChannel |
channel
The ConsumerChannel that this queue will read off of. |
protected Map |
channelStatus
Contains information regarding whether the ConsumerChannel is still an active channel from which to be
read. |
protected Map |
channelToThread
The mapping of the channel to the WorkerThread
currently executing it. |
protected util.Queue |
ordinaryObjects
all non- ReturnValue objects are buffeded on this queue. |
protected Map |
returnValues
ReturnValues are stored based on ID (as an Integer) in this map
when the are read in. |
private static long |
serialVersionUID
|
private int |
waiting
The number of Thread objects currently waiting to dequeue a ReturnValue. |
| Constructor Summary | |
protected |
ConsumerQueue()
|
|
ConsumerQueue(connect.ConsumerChannel channel)
|
| Method Summary | |
Object |
dequeue()
Dequeues an object from the ordinaryObjects queue (i.e. |
util.ReturnValue |
dequeue(int requestID)
Dequeue a ReturnValue matching the specific requestID. |
int |
getWaitingThreadCount()
Returns the number of threads currently waiting on a ReturnValue. |
boolean |
isActive()
Returns true if this is actively reading in objects from the channel. |
protected boolean |
isChannelActive(connect.ConsumerChannel channel)
Retuns the active status of the channel. |
protected void |
setActiveStatus(connect.ConsumerChannel channel,
boolean status)
Sets the active status of the channel, which determines whether the channel will continue reading in. |
protected util.WorkerThread |
startListeningThread(connect.ConsumerChannel channel)
Starts a WorkerThread to read in values and then
returns a reference to that thread. |
void |
stop()
Stops the reading in of the current ConsumerStream. |
protected void |
stopChannel(connect.ConsumerChannel channel)
Marks the channel as not active and then waits for the WorkerThread to notify it that the thread has finished. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static final long serialVersionUID
protected connect.ConsumerChannel channel
protected final Map channelStatus
ConsumerChannel is still an active channel from which to be
read.
protected final Map channelToThread
WorkerThread
currently executing it.
protected final util.Queue ordinaryObjects
ReturnValue objects are buffeded on this queue.
protected final Map returnValues
Integer) in this map
when the are read in.
private int waiting
ReturnValue.
| Constructor Detail |
public ConsumerQueue(connect.ConsumerChannel channel)
protected ConsumerQueue()
| Method Detail |
public util.ReturnValue dequeue(int requestID)
ReturnValue matching the specific requestID.
This method blocks until that ID is read in. The method knows
that the specified ID has been read in when it is notified by
the internal thread reading in that a new ReturnValue has been
read in. Then it checks the map to see if a ReturnValue has
been mapped to the ID (i.e. signifying that the ReturnValue is
of that key).
ReturnValue.getReturnValueID(),
MethodRequest.getReturnValueID()public Object dequeue()
public int getWaitingThreadCount()
ReturnValue.
public boolean isActive()
protected boolean isChannelActive(connect.ConsumerChannel channel)
protected util.WorkerThread startListeningThread(connect.ConsumerChannel channel)
WorkerThread to read in values and then
returns a reference to that thread. This method constantly
reads in off the ConsumerChannel. If the object that it reads
in is a ReturnValue, it put it in the Map using its ReturnID as
the key. Then it will notify all waiting parties that a new
value has been put in the mapping. If the object read in was
not a ReturnValue, then it is put in the ordinaryObjects queue.
Starting a channel automatically marks its status as being
active.
ordinaryObjects,
returnValues
protected void setActiveStatus(connect.ConsumerChannel channel,
boolean status)
public void stop()
ConsumerStream.
This method has the invariant that after returning, no
additional objects will be read from the queue.
protected void stopChannel(connect.ConsumerChannel channel)
WorkerThread to notify it that the thread has finished. This
method will only return when no additional objects will be read
in.
|
Boeing Simulation 3.1 API Specification | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||