Class ProcessSimulator
- java.lang.Object
-
- umontreal.iro.lecuyer.simevents.Simulator
-
- 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 theSimulatorclass 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
newInstancemethod 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 theinitDefaultmethod or setting the ssj.processes property.
-
-
Field Summary
-
Fields inherited from class umontreal.iro.lecuyer.simevents.Simulator
defaultSimulator
-
-
Constructor Summary
Constructors Constructor and Description ProcessSimulator()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract EventcreateControlEvent(SimProcess process)Constructs and returns a newEventobject used for synchronization.SimProcesscurrentProcess()Returns the currently active process for this simulator.abstract voiddelay(SimProcess process, double delay)Suspends the execution of process and schedules it to resume its execution in delay units of simulation time.static voidinitDefault()Initializes the default simulator to use processes.abstract voidkill(SimProcess process)Terminates the life of process and sets its state to DEAD, after canceling its control event if there is one.abstract voidkillAll()Kills all currently living (active, delayed, or suspended) processes managed by this simulator.static ProcessSimulatornewInstance()Constructs and returns a new process-oriented simulator.abstract voidsuspend(SimProcess process)Suspends process.-
Methods inherited from class umontreal.iro.lecuyer.simevents.Simulator
continuousState, getDefaultSimulator, getEventList, init, init, isSimulating, isStopped, start, stop, time
-
-
-
-
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 newEventobject 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 ofnewInstance.Warning: this method must be called before any event or process is constructed, otherwise the program could return some exceptions like
ClassCastExceptionorNullPointerException. 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
Simulatorfor 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 aThreadProcessSimulator. Otherwise, if the ssj.withDSOL system property is set, this returns aDSOLProcessSimulatorinstance. If no system property is set, this returns aThreadProcessSimulator.For example, if a program is called using java -Dssj.withDSOL ..., it will use DSOL for process simulation.
-
-
DMelt 3.0 © DataMelt by jWork.ORG