Package jadex.platform.service.execution
Class SyncExecutionService
- java.lang.Object
-
- jadex.bridge.service.BasicService
-
- jadex.platform.service.execution.SyncExecutionService
-
- All Implemented Interfaces:
IInternalService,IService,IExecutionService
- Direct Known Subclasses:
BisimExecutionService
public class SyncExecutionService extends BasicService implements IExecutionService
The synchronous execution service that executes all tasks in zero to one thread.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSyncExecutionService.StateThe possible states of the service.
-
Field Summary
Fields Modifier and Type Field Description protected ExecutorexecutorThe executor.protected Future<java.lang.Void>idlefutureThe idle future.protected IInternalAccessproviderThe provider.protected java.util.Set<IExecutable>queueThe queue of tasks to be executed.protected java.util.List<Future<java.lang.Void>>removedfutThe removed listeners.protected IExecutableremovedtaskFlag that indicates that the current task has been removed.protected SyncExecutionService.StatestateThe state of the service.protected IExecutabletaskThe current task.-
Fields inherited from class jadex.bridge.service.BasicService
idcnt, impltype, internalaccess, providerid, shutdowned, sid, started, type
-
Fields inherited from interface jadex.bridge.service.IService
EMPTY_SERVICES
-
-
Constructor Summary
Constructors Constructor Description SyncExecutionService(IInternalAccess provider)Create a new synchronous executor service.SyncExecutionService(IInternalAccess provider, java.util.Map<java.lang.String,java.lang.Object> properties)Create a new synchronous executor service.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IFuture<java.lang.Void>cancel(IExecutable task)Cancel a task.booleancustomIsValid()Test if the service is valid.voidexecute(IExecutable task)Execute a task.IFuture<java.lang.Void>getNextIdleFuture()Get the future indicating that executor is idle.IExecutable[]getRunningTasks()Get the currently running or waiting tasks.protected IThreadPoolServicegetThreadPool()Thread pool template method to support replacment.IFuture<java.lang.Void>shutdownService()Shutdown the executor service.IFuture<java.lang.Void>startService()Start the executor service.-
Methods inherited from class jadex.bridge.service.BasicService
createServiceIdentifier, createServiceIdentifier, equals, generateServiceName, getInterfaceType, getInternalAccess, getInvokeMethod, getMethodInfos, getMethodTimeout, getPropertyMap, getProviderId, getServiceId, hashCode, initNFProperties, invokeMethod, isValid, setComponentAccess, setPropertyMap, setServiceIdentifier, toString
-
-
-
-
Field Detail
-
queue
protected java.util.Set<IExecutable> queue
The queue of tasks to be executed.
-
executor
protected Executor executor
The executor.
-
idlefuture
protected volatile Future<java.lang.Void> idlefuture
The idle future.
-
state
protected SyncExecutionService.State state
The state of the service.
-
task
protected IExecutable task
The current task.
-
removedtask
protected IExecutable removedtask
Flag that indicates that the current task has been removed.
-
removedfut
protected java.util.List<Future<java.lang.Void>> removedfut
The removed listeners.
-
provider
protected IInternalAccess provider
The provider.
-
-
Constructor Detail
-
SyncExecutionService
public SyncExecutionService(IInternalAccess provider)
Create a new synchronous executor service.
-
SyncExecutionService
public SyncExecutionService(IInternalAccess provider, java.util.Map<java.lang.String,java.lang.Object> properties)
Create a new synchronous executor service.
-
-
Method Detail
-
execute
public void execute(IExecutable task)
Execute a task. Triggers the task to be executed in future.- Specified by:
executein interfaceIExecutionService- Parameters:
task- The task to execute.
-
cancel
public IFuture<java.lang.Void> cancel(IExecutable task)
Cancel a task. Triggers the task to be not executed in future.- Specified by:
cancelin interfaceIExecutionService- Parameters:
task- The task to execute.- Returns:
- Future signaling cancellation.
-
getRunningTasks
public IExecutable[] getRunningTasks()
Get the currently running or waiting tasks.- Specified by:
getRunningTasksin interfaceIExecutionService
-
customIsValid
public boolean customIsValid()
Test if the service is valid.- Returns:
- True, if service can be used.
-
startService
public IFuture<java.lang.Void> startService()
Start the executor service. Resumes all tasks.- Specified by:
startServicein interfaceIInternalService- Overrides:
startServicein classBasicService- Returns:
- A future that is done when the service has completed starting.
-
shutdownService
public IFuture<java.lang.Void> shutdownService()
Shutdown the executor service.- Specified by:
shutdownServicein interfaceIInternalService- Overrides:
shutdownServicein classBasicService- Returns:
- A future that is done when the service has completed its shutdown.
-
getNextIdleFuture
public IFuture<java.lang.Void> getNextIdleFuture()
Get the future indicating that executor is idle.- Specified by:
getNextIdleFuturein interfaceIExecutionService
-
getThreadPool
protected IThreadPoolService getThreadPool()
Thread pool template method to support replacment.
-
-