umontreal.iro.lecuyer.simprocs
Class Condition
- java.lang.Object
-
- java.util.Observable
-
- umontreal.iro.lecuyer.simprocs.Condition
-
public class Condition extends java.util.Observable
-
-
Constructor Summary
Constructors Constructor and Description Condition(boolean val)Constructs a new Condition with initial value val, linked with the default simulator.Condition(boolean val, java.lang.String name)Constructs a new Condition with initial value val, identifier name and linked with the default simulator.Condition(ProcessSimulator sim, boolean val)Constructs a new Condition with initial value val, linked with simulator sim.Condition(ProcessSimulator sim, boolean val, java.lang.String name)Constructs a new Condition with initial value val, identifier name and linked with simulator sim.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.StringgetName()Returns the name (or identifier) associated to this condition.voidinit(boolean val)Reinitializes this Condition by clearing up its waiting list and resetting its state to val.voidset(boolean val)Sets the condition to val.voidsetBroadcasting(boolean b)Instructs the condition to start or stop observation broadcasting.booleanstate()Returns the state (true or false) of the condition.voidwaitFor()The executing process invoking this method must wait for this condition to be true.LinkedListStatwaitList()Returns the list ofUserRecordfor the processes waiting for this condition.
-
-
-
Constructor Detail
-
Condition
public Condition(boolean val)
Constructs a new Condition with initial value val, linked with the default simulator.- Parameters:
val- initial state of the condition
-
Condition
public Condition(ProcessSimulator sim, boolean val)
Constructs a new Condition with initial value val, linked with simulator sim.- Parameters:
sim- current simulator of the variableval- initial state of the condition
-
Condition
public Condition(boolean val, java.lang.String name)Constructs a new Condition with initial value val, identifier name and linked with the default simulator.- Parameters:
val- initial state of the conditionname- identifier or name for the condition
-
Condition
public Condition(ProcessSimulator sim, boolean val, java.lang.String name)
Constructs a new Condition with initial value val, identifier name and linked with simulator sim.- Parameters:
sim- current simulator of the variableval- initial state of the conditionname- identifier or name for the condition
-
-
Method Detail
-
init
public void init(boolean val)
Reinitializes this Condition by clearing up its waiting list and resetting its state to val. The processes in this list (if any) remain in the same states.- Parameters:
val- initial state of the condition
-
set
public void set(boolean val)
Sets the condition to val. If val is true, all the processes waiting for this condition now resume their execution, in the same order as they have calledwaitForfor this condition. (Note that a process can never wait for more than one condition at a time, because it cannot callwaitForwhile it is suspended.- Parameters:
val- new state of the condition
-
state
public boolean state()
Returns the state (true or false) of the condition.- Returns:
- the current state of the condition
-
waitFor
public void waitFor()
The executing process invoking this method must wait for this condition to be true. If it is already true, the process continues its execution immediately Otherwise, the executing process is placed into thewaitListlist for this condition and is suspended until the condition becomes true.
-
waitList
public LinkedListStat waitList()
Returns the list ofUserRecordfor the processes waiting for this condition.- Returns:
- the list of processes user records waiting for the condition
-
getName
public java.lang.String getName()
Returns the name (or identifier) associated to this condition.- Returns:
- the name associated to this object
-
setBroadcasting
public void setBroadcasting(boolean b)
Instructs the condition to start or stop observation broadcasting. When this is turned ON, aBooleanobservation is notified to registered observers when the state of the condition changes. This boolean gives the new state of the condition.Warning: Since this can reduce program performance, this should be turned on only when there are registered observers.
- Parameters:
b- true to turn broadcasting ON, false to turn it OFF
-
-
DMelt 3.0 © DataMelt by jWork.ORG