package nl.tudelft.simulation.dsol.interpreter.process; import java.util.Stack; import org.djutils.event.EventProducer; import org.djutils.event.EventType; import org.djutils.logger.CategoryLogger; import org.djutils.reflection.ClassUtil; import nl.tudelft.simulation.dsol.interpreter.Frame; import nl.tudelft.simulation.dsol.interpreter.Interpreter; import nl.tudelft.simulation.dsol.interpreter.InterpreterException; /** * The Process class is an abstract Process which can be suspended and resumed. *
* Copyright (c) 2002-2021 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See * for project information https://simulation.tudelft.nl. The DSOL * project is distributed under a three-clause BSD-style license, which can be found at * * https://simulation.tudelft.nl/dsol/3.0/license.html. *
* @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) { CategoryLogger.always().warn(exception, "