Advanced Modelling FeaturesCondQueue
What Is a CondQueue? |
||
The desmoj.core.advancedModellingFeatures.CondQueue<P extends SimProcess> object (API) represents a very comfortable construct to synchronise processes of a certain type P. Its purpose is to allow processes to wait until a predefinied condition (system state) is met. Processes are automatically stored in an internal waiting queue and passivated. A process requests synchronisation by calling the waitUntil(Condition<P> cond) method of a CondQueue<P> object. It passes the condition (i.e. required system state) it is waiting for as a parameter of type Condition<P>. The CondQueue will then block the process -- insert it into its internal queue and passivate it -- until its condition evaluates to "true". There is no delay if the condition already holds when a process enters the CondQueue<P>.
In order to avoid slowing down the execution of a simulation, conditions are not tested automatically at every simulation time. Instead, other processes have to explicitly notify the CondQueue<P> after (relevant) changes of the system state occurred (e.g. when a new process arrived or an activity has finished) by calling the queue's signal() method. A model designer must ensure that this method is called where appropriate. Only when the condition queue receives a signal, waiting processes will be tested to see if they can now proceed. This is done by evaluating the check(P p) method of their Condition<P> object. By default, only the first waiting process will be looked at (thus assuming that all processes wait for the same condition). You can force the condition queue to test every waiting process by setting its checkAll attribute to true. If a process's condition is met, it is automatically removed from the queue and activated again. |
||
http://desmoj.sourceforge.net/tutorial/advanced/condqueue0.html |