Class ScriptingEngineThread

  • All Implemented Interfaces:
    Stoppable, Runnable

    public class ScriptingEngineThread
    extends Thread
    implements Stoppable
    A class for processing the scripting commands.
    fracpete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • m_Running

        protected boolean m_Running
        whether the thread is running.
      • m_Processing

        protected boolean m_Processing
        whether any command is currently being processed.
    • Constructor Detail

      • ScriptingEngineThread

        public ScriptingEngineThread​(AbstractScriptingEngine owner)
        Initializes the thread.
        owner - the owning scripting engine
    • Method Detail

      • clear

        public void clear()
        Clears the queue of scripting commands.
      • add

        public void add​(ScriptingCommand cmd)
        Adds the command to the queue.
        cmd - the command to add
      • stopExecution

        public void stopExecution()
        Stops the execution of scripting commands.
        Specified by:
        stopExecution in interface Stoppable
      • isRunning

        public boolean isRunning()
        Returns whether the thread is still active and waits for commands to execute.
        true if accepting commands to process
      • isProcessing

        public boolean isProcessing()
        Returns whether a command is currently being processed.
        true if a command is being processed
      • isEmpty

        public boolean isEmpty()
        Returns whether there are no commands currently in the queue.
        true if no commands waiting to be executed
      • preProcess

        protected void preProcess​(ScriptingCommand cmd)
        Performs some preprocessing.
        cmd - the command that is about to be executed
      • doProcess

        protected String doProcess​(ScriptingCommand cmd)
                            throws Exception
        Executes the given command.
        cmd - the command to execute
        the error message, null if no problems occurred
        Exception - if execution fails
      • postProcess

        protected void postProcess​(ScriptingCommand cmd,
                                   boolean success,
                                   String lastError)
        Performs some postprocessing.
        cmd - the command that was executed
        success - true if successfully executed
        lastError - the error, or null if none happened
      • run

        public void run()
        Executes the scripting commands.
        Specified by:
        run in interface Runnable
        run in class Thread