public class CondQueue<P extends SimProcess> extends QueueBased
waitUntil(condition)
and does not find this condition to be
true, is inserted in a waiting-queue automatically. Whenever something
happens which might influence the condition to become true
,
signal()
should be used to check if the first entity (or, if
the attribute checkAll
is set to true, all entities) in the
waiting-queue finds the desired condition now and therefore can continue. The
designer of the model is responsible that this check takes place! He also has
to implement the condition, this can easily be done by deriving it from the
interface Condition
. The flag, if only the first or all
entities in the queue are checking their conditions again, can be checked and
changed using getCheckAll()
and setCheckAll()
.
The first sort criterion of the queue is highest queueing priorities first
(i.e. not using scheduling priorities - note that this is a somewhat arbitrary
choice, as the CondQueue
is derived from QueueBased
, which provides all the statistical functionality
for a queue.QueueBased
QueueBased.QueueAction
FIFO, LIFO, RANDOM, UNDEFINED
Constructor and Description |
---|
CondQueue(Model owner,
java.lang.String name,
boolean showInReport,
boolean showInTrace)
Constructor for a CondQueue where processes can wait for a certain
condition to become true.
|
CondQueue(Model owner,
java.lang.String name,
int sortOrder,
int qCapacity,
boolean showInReport,
boolean showInTrace)
Constructor for a CondQueue where processes can wait for a certain
condition to become true.
|
Modifier and Type | Method and Description |
---|---|
Reporter |
createDefaultReporter()
Returns a Reporter to produce a report about this CondQueue.
|
P |
first()
Returns the first process waiting in the queue.
|
P |
first(Condition<P> cond)
Returns the first process waiting in the queue that complies to
the given condition.
|
boolean |
getCheckAll()
Returns if all entities or only the first one in the queue are getting a
signal to check their conditions.
|
java.lang.String |
getQueueStrategy()
Returns the implemented queueing discipline of the underlying queue
used for sorting (and, therefore, activation order) of processes
with equal queing priorities.
|
long |
getRefused()
Returns the number of entities refused to be enqueued in the queue,
because the capacity limit is reached.
|
void |
setCheckAll(boolean chckall)
Sets the flag
checkAll : if all entities or only the first
one in the queue are getting a signal to check their conditions. |
void |
signal()
A
signal () should be sent every time when a condition has
changed and might be true now. |
void |
waitCancel(P p)
Removes the given SimProcess from the Queue.
|
boolean |
waitUntil(Condition<P> cond)
Lets the current process wait in the CondQueue until a certain condition,
given as a parameter, has become true.
|
addObserver, averageLength, averageWaitTime, deleteObserver, getQueueLimit, length, maxLength, maxLengthAt, maxWaitTime, maxWaitTimeAt, minLength, minLengthAt, notifyObservers, reset, setQueueImpWarning, stdDevLength, stdDevWaitTime, zeroWaits
getCorrespondingSchedulable, getDescription, getObservations, getReporter, incrementObservations, incrementObservations, reportIsOn, reportOff, reportOn, resetAt, setCorrespondingSchedulable, setDescription, setReporter
current, currentEntity, currentEntityAll, currentEvent, currentModel, currentSimProcess, debugIsOn, debugOff, debugOn, getModel, isExperimentCompatible, isModelCompatible, presentTime, sendDebugNote, sendMessage, sendTraceNote, sendWarning, skipTraceNote, skipTraceNote, traceIsOn, traceOff, traceOn
getName, getQuotedName, toString
public CondQueue(Model owner, java.lang.String name, int sortOrder, int qCapacity, boolean showInReport, boolean showInTrace)
QueueBased
, e.g.
QueueBased.FIFO
or QueueBased.LIFO
.
The capacity limit of the underlying queue can be chosen.owner
- Model : The model this CondQueue is associated to.name
- java.lang.String : The CondQueue's namesortOrder
- int : determines the sort order of the underlying queue
implementation to use for sorting processes with equal
queing priorities. Choose a constant from QueueBased
like QueueBased.FIFO
or
QueueBased.LIFO
or ...qCapacity
- int : The capacity of the queue, that is how many processes
can be enqueued. Zero (0) means unlimited capacity.showInReport
- boolean : Flag, if CondQueue should produce a report or not.showInTrace
- boolean : Flag for trace to produce trace messages.public CondQueue(Model owner, java.lang.String name, boolean showInReport, boolean showInTrace)
owner
- Model : The model this CondQueue is associated to.name
- java.lang.String : The CondQueue's nameshowInReport
- boolean : Flag, if CondQueue should produce a report or not.showInTrace
- boolean : Flag for trace to produce trace messages.public Reporter createDefaultReporter()
public boolean getCheckAll()
false
, so that only the
first process in the queue is checking its condition.public java.lang.String getQueueStrategy()
String
,
inteded to be displayed in the report.public long getRefused()
public void setCheckAll(boolean chckall)
checkAll
: if all entities or only the first
one in the queue are getting a signal to check their conditions.chckall
- boolean : Flag if all entities in the queue should check their
conditions? Default is false
, so that only the
first entity in the queue is checking its condition.public void signal()
signal ()
should be sent every time when a condition has
changed and might be true now. It activates the first process in the
queue to check its condition again. Other processes might follow.
The order of process activation depends on the order of the internal
_queue
, which is based on the processes' queueing
priorities and (if queueing priorities are equal, requiring
a tie-breaker) by FIFO or a different discipline as defined in the
constructor.public P first()
null
is returned.null
if no process is waiting).public P first(Condition<P> cond)
null
is returned.cond
- Condition : The Condition cond
is describing the
condition to which the process must comply to. This has
to be implemented by the user in the class:
Condition
in the method: check()
.public void waitCancel(P p)
p
- P : The P to be removed from the queuepublic boolean waitUntil(Condition<P> cond) throws SuspendExecution
checkAll
is set to
true
the next process in the queue will be activated, too.
If the capacity limit of the queue is reached, the process will not be
enqueued and false
returned.cond
- Condition : The condition that has to become true before the
process can continue.true
if the process can be enqueued
successfully, false
otherwise (i.e. capacity limit
of the queue is reached).SuspendExecution
Condition