Package ptolemy.actor

Interface Executable

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int COMPLETED
      An indicator that the iterate() method completed successfully.
      static int NOT_READY
      An indicator that the iterate() method did not complete because the actor was not ready (prefire() returned false).
      static int STOP_ITERATING
      An indicator that the actor does not wish to be fired again.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void fire()
      Fire the actor.
      boolean isFireFunctional()
      Return true if this executable does not change state in either the prefire() or the fire() method.
      boolean isStrict()
      Return true if this executable is strict, meaning all inputs must be known before iteration.
      int iterate​(int count)
      Invoke a specified number of iterations of the actor.
      boolean postfire()
      This method should be invoked once per iteration, after the last invocation of fire() in that iteration.
      boolean prefire()
      This method should be invoked prior to each invocation of fire().
      void stop()
      Request that execution of this Executable stop as soon as possible.
      void stopFire()
      Request that execution of the current iteration complete.
      void terminate()
      Terminate any currently executing model with extreme prejudice.
    • Field Detail

      • COMPLETED

        static final int COMPLETED
        An indicator that the iterate() method completed successfully.
        See Also:
        Constant Field Values
      • NOT_READY

        static final int NOT_READY
        An indicator that the iterate() method did not complete because the actor was not ready (prefire() returned false).
        See Also:
        Constant Field Values
      • STOP_ITERATING

        static final int STOP_ITERATING
        An indicator that the actor does not wish to be fired again.
        See Also:
        Constant Field Values
    • Method Detail

      • fire

        void fire()
           throws IllegalActionException
        Fire the actor. This may be invoked several times between invocations of prefire() and postfire(). Output data may (and normally will) be produced. Typically, the fire() method performs the computation associated with an actor. This method is not required to have bounded execution. However, after endFire() is called, this method should return in bounded time.
        Throws:
        IllegalActionException - If firing is not permitted.
      • isFireFunctional

        boolean isFireFunctional()
        Return true if this executable does not change state in either the prefire() or the fire() method. A class that returns true is said to obey the actor abstract semantics. In particular, such an actor can be used in domains that have a fixed point semantics and may repeatedly fire the actor before committing to state changes.
        Returns:
        True if this executable only updates its states during an iteration in the postfire() method.
      • isStrict

        boolean isStrict()
                  throws IllegalActionException
        Return true if this executable is strict, meaning all inputs must be known before iteration. Normally, classes that implement this interface are strict, so this method will return true. However, some classes can perform an iteration even if some inputs are not known (i.e., these classes tolerate a return value of false from the isKnown() method of Receiver).
        Returns:
        True if this executable is strict, meaning all inputs must be known before iteration.
        Throws:
        IllegalActionException - Thrown by subclass.
      • iterate

        int iterate​(int count)
             throws IllegalActionException
        Invoke a specified number of iterations of the actor. An iteration here is equivalent to invoking prefire(), fire(), and postfire(), in that order. In an iteration, if prefire() returns true, then fire() will be called once, followed by postfire(). Otherwise, if prefire() returns false, fire() and postfire() are not invoked, and this method returns NOT_READY. If postfire() returns false, then no more iterations are invoked, and this method returns STOP_ITERATING. Otherwise, it returns COMPLETED.

        An implementation of this method is not required to actually invoke prefire(), fire(), and postfire(). An implementation of this method must, however, perform the equivalent operations.

        Note that this method for iterating an actor should be used only in domains where a single invocation of prefire() and fire() is sufficient in an iteration.

        Parameters:
        count - The number of iterations to perform.
        Returns:
        NOT_READY, STOP_ITERATING, or COMPLETED.
        Throws:
        IllegalActionException - If iterating is not permitted, or if prefire(), fire(), or postfire() throw it.
      • postfire

        boolean postfire()
                  throws IllegalActionException
        This method should be invoked once per iteration, after the last invocation of fire() in that iteration. The postfire() method should not produce output data on output ports of the actor. It returns true if the execution can proceed into the next iteration, false if the actor does not wish to be fired again. This method typically wraps up an iteration, which may involve updating local state or updating displays.
        Returns:
        True if the execution can continue.
        Throws:
        IllegalActionException - If postfiring is not permitted.
      • prefire

        boolean prefire()
                 throws IllegalActionException
        This method should be invoked prior to each invocation of fire(). It returns true if the fire() method can be invoked, given the current status of the inputs and parameters of the actor. Thus this method will typically check preconditions for a firing, if there are any. In an opaque, non-atomic entity, it may move data into an inner subsystem.
        Returns:
        True if the iteration can proceed.
        Throws:
        IllegalActionException - If prefiring is not permitted.
      • stop

        void stop()
        Request that execution of this Executable stop as soon as possible. An implementation of this method should pass on the request to any contained executable objects. An implementation should also return false from postfire() to indicate to the caller that no further execution of this Executable is appropriate. After this method is called, the executable object should not be fired again. The stopFire() method, by contrast, requests that the current iteration be completed, but not that the entire execution be stopped. I.e., the Executable may be fired again after stopFire() is called.
      • stopFire

        void stopFire()
        Request that execution of the current iteration complete. If an iteration is always a finite computation (the usual case), i.e. the fire() method always returns in finite time, then nothing needs to be done in this method, except possibly to pass on the request to any contained executable objects. This method is used to request that an unbounded computation suspend, returning control to the caller. Thus, if the fire() method does not normally return in finite time, then this method is used to request that it return. It should suspend execution in such a way that if the fire() method is called again, execution will resume at the point where it was suspended. However, it should not assume the fire() method will be called again. It is possible that the wrapup() method will be called next.
      • terminate

        void terminate()
        Terminate any currently executing model with extreme prejudice. This method is not intended to be used as a normal route of stopping execution. To normally stop execution, call the finish() method instead. This method should be called only when execution fails to terminate by normal means due to certain kinds of programming errors (infinite loops, threading errors, etc.).

        After this method completes, all resources in use should be released and any sub-threads should be killed. However, a consistent state is not guaranteed. The topology should probably be recreated before attempting any further operations. This method should not be synchronized because it must happen as soon as possible, no matter what.