public class WaitQueue<M extends SimProcess,S extends SimProcess> extends QueueBased
cooperate()
to signal that it is willing to cooperate as
a master. Slaves are calling waitOnCoop()
. The action performed
during the cooperation of the two processes has to be implemented in the
method cooperation()
in the class ProcessCoop
.
There are two waiting-queues, one for the masters and one for the slaves. If
there is no corresponding master or slave available, they are inserted in a
such a waiting-queue.
The first sort criterion of the queues is highest queueing priorities first
(i.e. not using scheduling priorities - note that this is a somewhat arbitrary
choice, as the WaitQueue
is derived from QueueBased
, which provides all
the statistical functionality for the masters' queue. The class holds a
reference to a ProcessQueue
where the slaves are waiting.QueueBased
,
ProcessCoop
QueueBased.QueueAction
FIFO, LIFO, RANDOM, UNDEFINED
Constructor and Description |
---|
WaitQueue(Model owner,
java.lang.String name,
boolean showInReport,
boolean showInTrace)
Constructor for a WaitQueue.
|
WaitQueue(Model owner,
java.lang.String name,
int mSortOrder,
int mQCapacity,
int sSortOrder,
int sQCapacity,
boolean showInReport,
boolean showInTrace)
Constructor for a WaitQueue.
|
Modifier and Type | Method and Description |
---|---|
S |
avail(Condition<S> cond)
Returns the slave process waiting in the slave queue and complying to the
given condition.
|
M |
availMaster(Condition<M> cond)
Returns the master process waiting in the master queue and complying to
the given condition.
|
boolean |
cancelCoop(SimProcess process)
Removes the given process from its queue and activates it.
|
boolean |
cooperate(ProcessCoop<M,S> coop)
This method is to be called from a
SimProcess which wants to
cooperate as a master. |
boolean |
cooperate(ProcessCoop<M,S> coop,
Condition<S> cond)
This method is called from a SimProcess which wants to cooperate as a
master and is looking for a slave complying to a certain condition
described in
cond . |
Reporter |
createDefaultReporter()
Returns a Reporter to produce a report about this WaitQueue.
|
long |
getCooperationsCompleted()
Returns the number of cooperations completed.
|
java.lang.String |
getMQueueStrategy()
Returns the implemented queueing discipline of the underlying master
queue as a String, so it can be displayed in the report.
|
long |
getMRefused()
Returns the number of entities refused to be enqueued in the master
queue, because the capacity limit is reached.
|
long |
getMRemoved()
Returns the number of entities which have been removed from the master
queue because
cancelCoop(SimProcess) has been called. |
ProcessQueue<S> |
getSlaveQueue()
Returns the
ProcessQueue where the waiting slaves are
stored. |
java.lang.String |
getSQueueStrategy()
Returns the implemented queueing discipline of the underlying slave queue
as a String, so it can be displayed in the report.
|
long |
getSRefused()
Returns the number of entities refused to be enqueued in the slave's
queue, because the capacity limit is reached.
|
long |
getSRemoved()
Returns the number of entities which have been removed from the slave
queue because
cancelCoop(SimProcess) has been called. |
TimeSpan |
mAverageCoopTime()
Returns the masters' (and slaves') time spent per cooperation
(accounting only for the cooperation itself, excluding waiting).
|
double |
mAverageLength()
Returns the average length of the underlying master queue since the last
reset.
|
TimeSpan |
mAverageWaitTime()
Returns the average waiting time of all processes who have exited the
master queue.
|
boolean |
mIsEmpty()
Returns a boolean value indicating if the master queue is empty or if any
number of SimProcess is currently enqueued in it.
|
long |
mLength()
Returns the current length of the master queue.
|
long |
mMaxLength()
Returns the maximum length of the underlying master queue since the last
reset.
|
TimeInstant |
mMaxLengthAt()
Returns the point of simulation time with the maximum number of processes
waiting inside the underlying master queue.
|
TimeSpan |
mMaxWaitTime()
Returns the maximum duration in simulation time that an process has spent
waiting inside the underlying master queue.
|
TimeInstant |
mMaxWaitTimeAt()
Returns the point of simulation time when the process with the maximum
waiting time exited the underlying master queue.
|
long |
mMinLength()
Returns the minimumn length of the underlying master queue since the last
reset.
|
TimeInstant |
mMinLengthAt()
Returns the point of simulation time with the minimum number of processes
waiting inside the underlying master queue.
|
double |
mStdDevLength()
Returns the standard deviation of the master queue's length.
|
TimeSpan |
mStdDevWaitTime()
Returns the standard deviation of the master queue's processes waiting
times.
|
long |
mZeroWaits()
Returns the number of processes that have passed through the master queue
without spending time waiting.
|
void |
reset()
Resets all statistical counters to their default values.
|
double |
sAverageLength()
Returns the average length of the slave queue since the last reset.
|
TimeSpan |
sAverageWaitTime()
Returns the average waiting time of all processes who have exited the
slave queue.
|
boolean |
sIsEmpty()
Returns a boolean value indicating if the slave queue is empty or if any
number of SimProcess is currently enqueued in it.
|
long |
sLength()
Returns the current length of the slave queue.
|
long |
sMaxLength()
Returns the maximum length of the slave queue since the last reset.
|
TimeInstant |
sMaxLengthAt()
Returns the point of simulation time with the maximum number of processes
waiting inside the slave queue.
|
TimeSpan |
sMaxWaitTime()
Returns the maximum duration in simulation time that an process has spent
waiting inside the slave queue.
|
TimeInstant |
sMaxWaitTimeAt()
Returns the point of simulation time when the process with the maximum
waiting time exited the slave queue.
|
long |
sMinLength()
Returns the minimumn length of the slave queue since the last reset.
|
TimeInstant |
sMinLengthAt()
Returns the point of simulation time with the minimum number of processes
waiting inside the slave queue.
|
double |
sStdDevLength()
Returns the standard deviation of the slave queue's length.
|
TimeSpan |
sStdDevWaitTime()
Returns the standard deviation of the slave queue's processes waiting
times.
|
long |
sZeroWaits()
Returns the number of processes that have passed through the slave queue
without spending time waiting.
|
boolean |
waitOnCoop()
This method is called from a SimProcess which wants to cooperate as a
slave.
|
addObserver, averageLength, averageWaitTime, deleteObserver, getQueueLimit, length, maxLength, maxLengthAt, maxWaitTime, maxWaitTimeAt, minLength, minLengthAt, notifyObservers, 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 WaitQueue(Model owner, java.lang.String name, int mSortOrder, int mQCapacity, int sSortOrder, int sQCapacity, boolean showInReport, boolean showInTrace)
QueueList
for the masters and one
separate ProcessQueue
for the slave processes. The queueing
discipline and the capacity limit of the underlying queues can be chosen.
Highest priority are always first in the queues.owner
- Model : The model this WaitQueue is associated to.name
- java.lang.String : The WaitQueue's namemSortOrder
- int : determines the sort order of the underlying master queue
implementation. Choose a constant from QueueBased
like QueueBased.FIFO
or
QueueBased.LIFO
or ...mQCapacity
- int : The capacity of the master queue, that is how many
processes can be enqueued. Zero (0) means unlimited capacity.sSortOrder
- int : determines the sort order of the underlying slave queue
implementation. Choose a constant from QueueBased
like QueueBased.FIFO
or
QueueBased.LIFO
or ...sQCapacity
- int : The capacity of the slave queue, that is how many
processes can be enqueued. Zero (0) means unlimited capacity.showInReport
- boolean : Flag, if WaitQueue should produce a report or not.showInTrace
- boolean : Flag for trace to produce trace messages.public WaitQueue(Model owner, java.lang.String name, boolean showInReport, boolean showInTrace)
QueueList
for the masters and one
separate ProcessQueue
for the slave processes. Both queues
have a FIFO sort order and no capacity limit.owner
- Model : The model this WaitQueue is associated to.name
- java.lang.String : The WaitQueue's nameshowInReport
- boolean : Flag, if WaitQueue should produce a report or not.showInTrace
- boolean : Flag, if trace messages of this WaitQueue should be
displayed in the trace file.public S avail(Condition<S> cond)
null
is returned.cond
- Condition : The Condition cond
is describing the
condition to which the slave process must comply to. This has
to be implemented by the user in the class:
Condition
in the method: check()
.public M availMaster(Condition<M> cond)
null
is returned.cond
- Condition : The Condition cond
is describing the
condition to which the master process must comply to. This has
to be implemented by the user in the class:
Condition
in the method: check()
.public boolean cancelCoop(SimProcess process)
true
is returned.process
- SimProcess : The process to be removed.true
if the process can be removed from
its queue, false
otherwisepublic boolean cooperate(ProcessCoop<M,S> coop) throws SuspendExecution
SimProcess
which wants to
cooperate as a master. If no suitable slave process is available at the
moment, the master process will be stored in the master waiting-queue
(order is based on the master's queueing priorities with tie-breaking
based on the queue's discipline as set in the constructor).
until a suitable slave is available. If the capacity limit of the master
queue is reached, the process will not be enqueued and false
returned. When a suitable slave is available its cooperate
method (in the class SimProcess
) will be called. During the
cooperation the master process is the only active one. The slave process
is passive and will be reactivated after the cooperation is done.coop
- ProcessCoop : The Process cooperation coop is describing the
joint action of the two processes. The action to be carried
out has to be implemented by the user in the class:
ProcessCoop
in the method:
cooperation()
.true
if the process can be enqueued
successfully, false
otherwise (i.e. capacity limit
of the master queue is reached).SuspendExecution
public boolean cooperate(ProcessCoop<M,S> coop, Condition<S> cond) throws SuspendExecution
cond
. If no suitable slave process with this
condition is available at the moment, the master process will be stored
in the master waiting-queue, until a suitable slave is available.
(order is based on the master's queueing priorities with tie-breaking
based on the queue's discipline as set in the constructor). If the
capacity limit of the master queue is reached, the process will not be
enqueued and false
returned. During the cooperation the
master process is the only active one. The slave process is passive and
will be reactivated after the cooperation is done.coop
- ProcessCoop : The Process cooperation coop is describing the
joint action of the two processes. This has to be implemented
by the user in the class: ProcessCoop
in the
method: cooperation
.cond
- Condition : The Condition cond
is describing the
condition to which the slave process must comply to. This has
to be implemented by the user in the class:
Condition
in the method: check()
.true
if the process can be enqueued
successfully, false
otherwise (i.e. capacity limit
of the master queue is reached).SuspendExecution
public Reporter createDefaultReporter()
public java.lang.String getMQueueStrategy()
public long getMRefused()
public long getMRemoved()
cancelCoop(SimProcess)
has been called.public long getCooperationsCompleted()
public ProcessQueue<S> getSlaveQueue()
ProcessQueue
where the waiting slaves are
stored.ProcessQueue
where the slaves are
waiting on masters to cooperate with.public java.lang.String getSQueueStrategy()
public long getSRefused()
public long getSRemoved()
cancelCoop(SimProcess)
has been called.public double mAverageLength()
public TimeSpan mAverageWaitTime()
public TimeSpan mAverageCoopTime()
public boolean mIsEmpty()
true
if the master queue is empty,
false
otherwisepublic long mLength()
public long mMaxLength()
public TimeInstant mMaxLengthAt()
public TimeSpan mMaxWaitTime()
public TimeInstant mMaxWaitTimeAt()
public long mMinLength()
public TimeInstant mMinLengthAt()
public double mStdDevLength()
public TimeSpan mStdDevWaitTime()
public long mZeroWaits()
public void reset()
reset
in class QueueBased
public double sAverageLength()
public TimeSpan sAverageWaitTime()
public boolean sIsEmpty()
true
if the slave queue is empty,
false
otherwisepublic long sLength()
public long sMaxLength()
public TimeInstant sMaxLengthAt()
public TimeSpan sMaxWaitTime()
public TimeInstant sMaxWaitTimeAt()
public long sMinLength()
public TimeInstant sMinLengthAt()
public double sStdDevLength()
public TimeSpan sStdDevWaitTime()
public long sZeroWaits()
public boolean waitOnCoop() throws SuspendExecution
false
returned. During the
cooperation the master process is the only active one. The slave process
is passive and will be reactivated after the cooperation is done.true
if the process can be enqueued
successfully, false
otherwise (i.e. capacity limit
of the slave queue is reached).SuspendExecution