|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--scorej.SignalWait
|
+--scorej.SignalWaitQueue
SignalWaitQueue is an subclass of SignalWait that encapsulates a FIFO Queue of signals. It behaves just as a SignalWait object, except that it is never removed from the signalWait list of the SignalProcessor. So, it is always active and ready to match signals. When a signal matches, that matching signal is pushed onto a queue. Processes can pop signals off the queue by calling S.waitForSignalQueue or pop.
SignalWaitQueues are not necessary if you are using a SimulationClock, since a simple waitForSignal inside of an infinite loop would work just as well. Though, you can use these SignalWaitQueues if you so choose. SignalWaitQueues are important for NonSimulationClocks, since the canonical loop-forever/waitForSignal could miss signals that arrive while one is being processed.
Use S.createSignalQueue to make a queue and register it. Use S.waitForSignalQueue to grab a signal off a queue (or wait for one)
SignalWait,
NonSimulationClock,
S| Field Summary | |
protected java.util.Vector |
signalQueue
|
protected java.util.Vector |
waitingThreads
|
| Fields inherited from class scorej.SignalWait |
_pattern, _receiver, _sender, _signalEvaluator, _subject, _thread |
| Method Summary | |
void |
clear()
Removes all signals from the queue. |
Signal |
elementAt(int index)
Returns the signal at the specified index. |
Signal |
findMatch(ID receiver,
ID sender,
java.lang.String[] subject,
java.lang.Object[] pattern,
SignalEvaluator func)
Tries to find a signal in the Queue with same values of receiver, sender, subject, pattern and evaluator specified in the argument list. |
int |
getWaitingThreadCount()
Returns how many threads are waiting for this queue |
boolean |
isEmpty()
Tests if the queue contains no signals. |
boolean |
matchSignal(Signal signal)
Notify the thread waiting using this SignalWait that the signal arrived. |
Signal |
peek()
Peeks at the next signal in the queue without removing it from the queue. |
Signal |
pop()
Pops a signal off the queue. |
boolean |
remove(Signal sig)
Removes the first signal from the queue that matches the specified signal If the queue does not contain the specified signal, the queue is unchanged. |
void |
setMatchedSignal(Signal signal)
Adds a signal to the queue. |
int |
size()
Returns the number of signals in the queue. |
java.lang.String |
toString()
Returns a string representation of the SignalWaitQueue object. |
Signal |
waitForSignal()
Waits for a Signal to arrive in the queue. |
Signal |
waitForSignal(ID receiver,
ID sender,
java.lang.String[] subject,
java.lang.Object[] pattern,
SignalEvaluator func)
Waits for a Signal to arrive in the queue that matches
against the receiver, sender, subject, pattern and evaluator contained
in the argument list. |
| Methods inherited from class scorej.SignalWait |
getMatchedSignal, getPattern, getReceiver, getSender, getSubject, matches |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.util.Vector signalQueue
protected java.util.Vector waitingThreads
| Method Detail |
public void setMatchedSignal(Signal signal)
setMatchedSignal in class SignalWait
public Signal findMatch(ID receiver,
ID sender,
java.lang.String[] subject,
java.lang.Object[] pattern,
SignalEvaluator func)
public void clear()
public Signal pop()
public boolean remove(Signal sig)
sig - Signal to be removed, if present.
public Signal peek()
public Signal elementAt(int index)
public int size()
public boolean isEmpty()
public int getWaitingThreadCount()
public java.lang.String toString()
toString in class SignalWaitpublic Signal waitForSignal()
Signal to arrive in the queue.
If the queue already contained one or more signals, at the time this
call was made, this call removes the first signal in the queue and returns
it. If the queue was empty when the call was made, this call blocks until
a signal arrives in the queue.
public Signal waitForSignal(ID receiver,
ID sender,
java.lang.String[] subject,
java.lang.Object[] pattern,
SignalEvaluator func)
Signal to arrive in the queue that matches
against the receiver, sender, subject, pattern and evaluator contained
in the argument list.
If the queue already contained one or more of such matching signals,
at the time this call was made, this call removes the first matching signal
in the queue and returns it. If the queue was empty when the call was
made, this call blocks until a matching signal arrives in the queue.
public boolean matchSignal(Signal signal)
matchSignal in class SignalWait
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||