SSJ
V. 2.6.2.

umontreal.iro.lecuyer.simprocs
Class Condition

java.lang.Object
  extended by java.util.Observable
      extended by umontreal.iro.lecuyer.simprocs.Condition

public class Condition
extends Observable

A Condition is a boolean indicator, with a list of processes waiting for the indicator to be true (when it is false). A process calling waitFor on a condition that is currently false is suspended until the condition becomes true. The list of waiting processes can be accessed via waitList.


Constructor Summary
Condition(boolean val)
          Constructs a new Condition with initial value val, linked with the default simulator.
Condition(boolean val, 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, String name)
          Constructs a new Condition with initial value val, identifier name and linked with simulator sim.
 
Method Summary
 String getName()
          Returns the name (or identifier) associated to this condition.
 void init(boolean val)
          Reinitializes this Condition by clearing up its waiting list and resetting its state to val.
 void set(boolean val)
          Sets the condition to val.
 void setBroadcasting(boolean b)
          Instructs the condition to start or stop observation broadcasting.
 boolean state()
          Returns the state (true or false) of the condition.
 void waitFor()
          The executing process invoking this method must wait for this condition to be true.
 LinkedListStat waitList()
          Returns the list of UserRecord for the processes waiting for this condition.
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 variable
val - initial state of the condition

Condition

public Condition(boolean val,
                 String name)
Constructs a new Condition with initial value val, identifier name and linked with the default simulator.

Parameters:
val - initial state of the condition
name - identifier or name for the condition

Condition

public Condition(ProcessSimulator sim,
                 boolean val,
                 String name)
Constructs a new Condition with initial value val, identifier name and linked with simulator sim.

Parameters:
sim - current simulator of the variable
val - initial state of the condition
name - 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 called waitFor for this condition. (Note that a process can never wait for more than one condition at a time, because it cannot call waitFor while 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 the waitList list for this condition and is suspended until the condition becomes true.


waitList

public LinkedListStat waitList()
Returns the list of UserRecord for the processes waiting for this condition.

Returns:
the list of processes user records waiting for the condition

getName

public 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, a Boolean observation 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

SSJ
V. 2.6.2.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.