package nl.tudelft.simulation.dsol.interpreter.process; import java.util.Stack; import nl.tudelft.simulation.dsol.interpreter.Frame; import nl.tudelft.simulation.dsol.interpreter.Interpreter; import nl.tudelft.simulation.dsol.interpreter.InterpreterException; import nl.tudelft.simulation.event.EventProducer; import nl.tudelft.simulation.event.EventType; import nl.tudelft.simulation.language.reflection.ClassUtil; import nl.tudelft.simulation.logger.Logger; /** * The Process class is an abstract Process which can be suspended and resumed. *
* (c) copyright 2002-2014 Delft University of Technology.
* BSD-style license. See DSOL License.
* @author Peter Jacobs
* @author Alexander Verbraeck
*/
public abstract class InterpretableProcess extends EventProducer
{
/** */
private static final long serialVersionUID = 20140830L;
/** the initial state. */
public static final short INITIAL = 0;
/** the initial state. */
public static final short EXECUTING = 1;
/** the initial state. */
public static final short SUSPENDED = 2;
/** the initial state. */
public static final short DEAD = 3;
/** the EventType. */
public static final EventType STATE_CHANGE_EVENT = new EventType("STATE_CHANGE_EVENT");
/** the state of the process. */
private short state = InterpretableProcess.INITIAL;
/** the processStack of this process. */
private final Stack frameStack = new Stack();
/**
* constructs a new Process.
*/
public InterpretableProcess()
{
super();
try
{
this.frameStack.push(Interpreter.createFrame(this, ClassUtil.resolveMethod(this, "process", null), null));
}
catch (Exception exception)
{
Logger.warning(this, "