Package jadex.execution.impl
Class ExecutionFeature
java.lang.Object
jadex.execution.impl.ExecutionFeature
- All Implemented Interfaces:
IExecutionFeature,IInternalExecutionFeature
public class ExecutionFeature
extends Object
implements IExecutionFeature, IInternalExecutionFeature
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classprotected class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected jadex.future.Future<Object> protected Objectprotected static Set<jadex.execution.impl.ExecutionFeature.TimerTaskInfo> protected booleanprotected List<IStepListener> static final ThreadLocal<ExecutionFeature> Provide access to the execution feature when running inside a component.protected ExecutionFeature.ThreadRunnerprotected jadex.core.impl.Componentprotected booleanprotected Set<ExecutionFeature.ComponentSuspendable> Keep track of threads in use to unblock on terminate. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a step listener.protected voidprotected voidprotected <T> voidbeforeBlock(jadex.future.Future<T> fut) protected voidprotected voidbusy()Template method to schedule operations whenever execution starts/resumes.voidTemplate method to allow augmentation/alteration of step execution.protected voidjadex.core.IComponentGet the component to which this feature belongs.longgetTime()Get the current time.protected voididle()Template method to schedule operations whenever execution temporarily ends, i.e., there are currently no more steps to execute.booleanTest if the current thread is used for current component execution.voidRemove a step listener.protected voidrestart()(Re-)Start the execution thread.protected booleansaveEndStep(Object res, jadex.future.Future<Object> fut) voidscheduleStep(jadex.core.IThrowingConsumer<jadex.core.IComponent> step) Schedule a step that provides a result.<T> jadex.future.IFuture<T> scheduleStep(jadex.core.IThrowingFunction<jadex.core.IComponent, T> step) Schedule a step that provides a result.voidSchedule a step to be run on the component.<T> jadex.future.IFuture<T> scheduleStep(Callable<T> s) Schedule a step that provides a result.voidTerminate the feature.jadex.future.ITerminableFuture<Void> waitForDelay(long millis) Wait a specific amount.
-
Field Details
-
LOCAL
Provide access to the execution feature when running inside a component. -
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
-
endfuture
-
entries
-
threads
Keep track of threads in use to unblock on terminate. -
listeners
-
-
Constructor Details
-
ExecutionFeature
public ExecutionFeature()
-
-
Method Details
-
getComponent
public jadex.core.IComponent getComponent()Description copied from interface:IExecutionFeatureGet the component to which this feature belongs.- Specified by:
getComponentin interfaceIExecutionFeature
-
scheduleStep
Description copied from interface:IExecutionFeatureSchedule a step to be run on the component.- Specified by:
scheduleStepin interfaceIExecutionFeature- Parameters:
r- A step that is executed via theRunnable.run()method.
-
scheduleStep
Description copied from interface:IExecutionFeatureSchedule a step that provides a result.- Specified by:
scheduleStepin interfaceIExecutionFeature- Parameters:
s- A step that is executed via theSupplier.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:
scheduleStepin interfaceIExecutionFeature- Parameters:
step- A step that is executed via theSupplier.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:
scheduleStepin interfaceIExecutionFeature- Parameters:
step- A step that is executed via theSupplier.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:
isComponentThreadin interfaceIExecutionFeature- Returns:
- True, if it is the currently executing component thread.
-
waitForDelay
Description copied from interface:IExecutionFeatureWait a specific amount.- Specified by:
waitForDelayin interfaceIExecutionFeature- 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:IExecutionFeatureGet the current time.- Specified by:
getTimein interfaceIExecutionFeature- 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
Description copied from interface:IInternalExecutionFeatureAdd a step listener.- Specified by:
addStepListenerin interfaceIInternalExecutionFeature
-
removeStepListener
Description copied from interface:IInternalExecutionFeatureRemove a step listener.- Specified by:
removeStepListenerin interfaceIInternalExecutionFeature
-
terminate
public void terminate()Description copied from interface:IInternalExecutionFeatureTerminate the feature.- Specified by:
terminatein interfaceIInternalExecutionFeature
-
beforeStep
protected void beforeStep() -
afterStep
protected void afterStep() -
beforeBlock
protected <T> void beforeBlock(jadex.future.Future<T> fut) -
afterBlock
protected void afterBlock() -
doRun
Template method to allow augmentation/alteration of step execution. Responsible for beforeStep/afterStep calls. -
restart
protected void restart()(Re-)Start the execution thread. -
saveEndStep
-
executeEndStep
protected void executeEndStep()
-