SSJ
V. 2.6.2.

umontreal.iro.lecuyer.simprocs
Class ProcessSimulator

java.lang.Object
  extended by umontreal.iro.lecuyer.simevents.Simulator
      extended by umontreal.iro.lecuyer.simprocs.ProcessSimulator
Direct Known Subclasses:
DSOLProcessSimulator, ThreadProcessSimulator

public abstract class ProcessSimulator
extends Simulator

Defines a special type of simulator capable of managing processes. This class extends the Simulator class with methods providing basic facilities used by process simulators to suspend, resume, and kill processes. It also specifies a mechanism for creating control events used for process synchronization. These methods are not called directly by the user, but they need to be implemented by any framework managing processes.

A process simulator is usually constructed by the newInstance method which selects the appropriate implementation based on system properties. It can also be constructed manually by calling the appropriate constructor explicitly. A default, implicit, simulator can also be used for compatibility with older programs. This can be done by calling the initDefault method or setting the ssj.processes property.


Field Summary
 
Fields inherited from class umontreal.iro.lecuyer.simevents.Simulator
defaultSimulator
 
Constructor Summary
ProcessSimulator()
           
 
Method Summary
abstract  Event createControlEvent(SimProcess process)
          Constructs and returns a new Event object used for synchronization.
 SimProcess currentProcess()
          Returns the currently active process for this simulator.
abstract  void delay(SimProcess process, double delay)
          Suspends the execution of process and schedules it to resume its execution in delay units of simulation time.
static void initDefault()
          Initializes the default simulator to use processes.
abstract  void kill(SimProcess process)
          Terminates the life of process and sets its state to DEAD, after canceling its control event if there is one.
abstract  void killAll()
          Kills all currently living (active, delayed, or suspended) processes managed by this simulator.
static ProcessSimulator newInstance()
          Constructs and returns a new process-oriented simulator.
abstract  void suspend(SimProcess process)
          Suspends process.
 
Methods inherited from class umontreal.iro.lecuyer.simevents.Simulator
continuousState, getDefaultSimulator, getEventList, init, init, isSimulating, isStopped, start, stop, time
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessSimulator

public ProcessSimulator()
Method Detail

currentProcess

public SimProcess currentProcess()
Returns the currently active process for this simulator.


createControlEvent

public abstract Event createControlEvent(SimProcess process)
Constructs and returns a new Event object used for synchronization. Such control events are used by process simulator to start a process or to resume it if it is already started.


delay

public abstract void delay(SimProcess process,
                           double delay)
Suspends the execution of process and schedules it to resume its execution in delay units of simulation time. The state of the process also changes to DELAYED.

Parameters:
process - SimProcess variable to delay.
delay - delay value, in simulation time units.

suspend

public abstract void suspend(SimProcess process)
Suspends process. If the process is EXECUTING, this suspends its execution. If the process is DELAYED, this cancels its control event. This method also places the process in the SUSPENDED state.

Parameters:
process - SimProcess variable to suspend.

kill

public abstract void kill(SimProcess process)
Terminates the life of process and sets its state to DEAD, after canceling its control event if there is one.


killAll

public abstract void killAll()
Kills all currently living (active, delayed, or suspended) processes managed by this simulator.


initDefault

public static void initDefault()
Initializes the default simulator to use processes. If the field Simulator.defaultSimulator is already initialized to a class extending ProcessSimulator, this method does nothing. Otherwise, it initializes the field to the return value of newInstance.

Warning: this method must be called before any event or process is constructed, otherwise the program could return some exceptions like ClassCastException or NullPointerException. Alternatively, one can set the ssj.processes system property, which instructs this class to call this method at the time it is loaded.

The aim of this method is to allow the user to use default process-oriented simulation without giving options to the Java Virtual Machine. See package simevents and class Simulator for more information about the default simulator.


newInstance

public static ProcessSimulator newInstance()
Constructs and returns a new process-oriented simulator. This method selects the concrete subclass of process simulator as follows. If the ssj.processSimulator system property is set, this gives the fully qualified class name of the process simulator to be instantiated. The given class must not be abstract, and must have a no-argument constructor. Otherwise, if the ssj.withThread system property is set, this returns a ThreadProcessSimulator. Otherwise, if the ssj.withDSOL system property is set, this returns a DSOLProcessSimulator instance. If no system property is set, this returns a ThreadProcessSimulator.

For example, if a program is called using java -Dssj.withDSOL ..., it will use DSOL for process simulation.


SSJ
V. 2.6.2.

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