Class ExecutionFeature

java.lang.Object
jadex.execution.impl.ExecutionFeature
All Implemented Interfaces:
IExecutionFeature, IInternalExecutionFeature

public class ExecutionFeature extends Object implements IExecutionFeature, IInternalExecutionFeature
  • Field Details

    • LOCAL

      public static final ThreadLocal<ExecutionFeature> LOCAL
      Provide access to the execution feature when running inside a component.
    • steps

      protected Queue<Runnable> steps
    • executing

      protected volatile boolean executing
    • do_switch

      protected volatile boolean do_switch
    • terminated

      protected boolean terminated
    • runner

    • self

      protected jadex.core.impl.Component self
    • endstep

      protected Object endstep
    • endfuture

      protected jadex.future.Future<Object> endfuture
    • entries

      protected static volatile Set<jadex.execution.impl.ExecutionFeature.TimerTaskInfo> entries
    • threads

      Keep track of threads in use to unblock on terminate.
    • listeners

      protected List<IStepListener> listeners
  • Constructor Details

    • ExecutionFeature

      public ExecutionFeature()
  • Method Details

    • getComponent

      public jadex.core.IComponent getComponent()
      Description copied from interface: IExecutionFeature
      Get the component to which this feature belongs.
      Specified by:
      getComponent in interface IExecutionFeature
    • scheduleStep

      public void scheduleStep(Runnable r)
      Description copied from interface: IExecutionFeature
      Schedule a step to be run on the component.
      Specified by:
      scheduleStep in interface IExecutionFeature
      Parameters:
      r - A step that is executed via the Runnable.run() method.
    • scheduleStep

      public <T> jadex.future.IFuture<T> scheduleStep(Callable<T> s)
      Description copied from interface: IExecutionFeature
      Schedule a step that provides a result.
      Specified by:
      scheduleStep in interface IExecutionFeature
      Parameters:
      s - A step that is executed via the Supplier.get() method.
      Returns:
      A future that provides access to the step result, once it is available.
    • scheduleStep

      public void scheduleStep(jadex.core.IThrowingConsumer<jadex.core.IComponent> step)
      Schedule a step that provides a result.
      Specified by:
      scheduleStep in interface IExecutionFeature
      Parameters:
      step - A step that is executed via the Supplier.get() method.
    • scheduleStep

      public <T> jadex.future.IFuture<T> scheduleStep(jadex.core.IThrowingFunction<jadex.core.IComponent,T> step)
      Schedule a step that provides a result.
      Specified by:
      scheduleStep in interface IExecutionFeature
      Parameters:
      step - A step that is executed via the Supplier.get() method.
      Returns:
      A future that provides access to the step result, once it is available.
    • isComponentThread

      public boolean isComponentThread()
      Test if the current thread is used for current component execution.
      Specified by:
      isComponentThread in interface IExecutionFeature
      Returns:
      True, if it is the currently executing component thread.
    • waitForDelay

      public jadex.future.ITerminableFuture<Void> waitForDelay(long millis)
      Description copied from interface: IExecutionFeature
      Wait a specific amount.
      Specified by:
      waitForDelay in interface IExecutionFeature
      Parameters:
      millis - The time to wait (in milliseconds).
      Returns:
      A future that is finished when the time has passed.
    • getTime

      public long getTime()
      Description copied from interface: IExecutionFeature
      Get the current time.
      Specified by:
      getTime in interface IExecutionFeature
      Returns:
      The time in milliseconds.
    • idle

      protected void idle()
      Template method to schedule operations whenever execution temporarily ends, i.e., there are currently no more steps to execute. This method is called while holding the lock on the steps queue. Make sure not to call any external activities when overriding this method, otherwise deadlocks might occur. Preferably, you should use scheduleStep() to execute your activity after the method call ends.
    • busy

      protected void busy()
      Template method to schedule operations whenever execution starts/resumes. This method is called while holding the lock on the steps queue. Make sure not to call any external activities when overriding this method, otherwise deadlocks might occur. Preferably, you should use scheduleStep() to execute your activity after the method call ends.
    • addStepListener

      public void addStepListener(IStepListener lis)
      Description copied from interface: IInternalExecutionFeature
      Add a step listener.
      Specified by:
      addStepListener in interface IInternalExecutionFeature
    • removeStepListener

      public void removeStepListener(IStepListener lis)
      Description copied from interface: IInternalExecutionFeature
      Remove a step listener.
      Specified by:
      removeStepListener in interface IInternalExecutionFeature
    • terminate

      public void terminate()
      Description copied from interface: IInternalExecutionFeature
      Terminate the feature.
      Specified by:
      terminate in interface IInternalExecutionFeature
    • beforeStep

      protected void beforeStep()
    • afterStep

      protected void afterStep()
    • beforeBlock

      protected <T> void beforeBlock(jadex.future.Future<T> fut)
    • afterBlock

      protected void afterBlock()
    • doRun

      public void doRun(Runnable step)
      Template method to allow augmentation/alteration of step execution. Responsible for beforeStep/afterStep calls.
    • restart

      protected void restart()
      (Re-)Start the execution thread.
    • saveEndStep

      protected boolean saveEndStep(Object res, jadex.future.Future<Object> fut)
    • executeEndStep

      protected void executeEndStep()