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 class
protected class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected jadex.future.Future
<Object> protected Object
protected static Set
<jadex.execution.impl.ExecutionFeature.TimerTaskInfo> protected boolean
protected List
<IStepListener> static final ThreadLocal
<ExecutionFeature> Provide access to the execution feature when running inside a component.protected ExecutionFeature.ThreadRunner
protected jadex.core.impl.Component
protected boolean
protected Set
<ExecutionFeature.ComponentSuspendable> Keep track of threads in use to unblock on terminate. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a step listener.protected void
protected void
protected <T> void
beforeBlock
(jadex.future.Future<T> fut) protected void
protected void
busy()
Template method to schedule operations whenever execution starts/resumes.void
Template method to allow augmentation/alteration of step execution.protected void
jadex.core.IComponent
Get the component to which this feature belongs.long
getTime()
Get the current time.protected void
idle()
Template method to schedule operations whenever execution temporarily ends, i.e., there are currently no more steps to execute.boolean
Test if the current thread is used for current component execution.void
Remove a step listener.protected void
restart()
(Re-)Start the execution thread.protected boolean
saveEndStep
(Object res, jadex.future.Future<Object> fut) void
scheduleStep
(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.void
Schedule a step to be run on the component.<T> jadex.future.IFuture
<T> scheduleStep
(Callable<T> s) Schedule a step that provides a result.void
Terminate 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:IExecutionFeature
Get the component to which this feature belongs.- Specified by:
getComponent
in interfaceIExecutionFeature
-
scheduleStep
Description copied from interface:IExecutionFeature
Schedule a step to be run on the component.- Specified by:
scheduleStep
in interfaceIExecutionFeature
- Parameters:
r
- A step that is executed via theRunnable.run()
method.
-
scheduleStep
Description copied from interface:IExecutionFeature
Schedule a step that provides a result.- Specified by:
scheduleStep
in 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:
scheduleStep
in 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:
scheduleStep
in 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:
isComponentThread
in interfaceIExecutionFeature
- Returns:
- True, if it is the currently executing component thread.
-
waitForDelay
Description copied from interface:IExecutionFeature
Wait a specific amount.- Specified by:
waitForDelay
in 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:IExecutionFeature
Get the current time.- Specified by:
getTime
in 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:IInternalExecutionFeature
Add a step listener.- Specified by:
addStepListener
in interfaceIInternalExecutionFeature
-
removeStepListener
Description copied from interface:IInternalExecutionFeature
Remove a step listener.- Specified by:
removeStepListener
in interfaceIInternalExecutionFeature
-
terminate
public void terminate()Description copied from interface:IInternalExecutionFeature
Terminate the feature.- Specified by:
terminate
in 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()
-