Package jadex.platform.service.execution
Class AsyncExecutionService
- java.lang.Object
- 
- jadex.bridge.service.BasicService
- 
- jadex.platform.service.execution.AsyncExecutionService
 
 
- 
- All Implemented Interfaces:
- IInternalService,- IService,- IExecutionService
 
 public class AsyncExecutionService extends BasicService implements IExecutionService The asynchronous executor service that executes all tasks in separate executors.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classAsyncExecutionService.StateThe possible states of the service.
 - 
Field SummaryFields Modifier and Type Field Description protected IInternalAccesscomponentThe component.protected java.util.Map<IExecutable,Executor>executorsThe currently waiting tasks (task->executor).protected Future<java.lang.Void>idlefutureThe idle future.protected java.util.Map<IExecutable,Executor>runningexesThe running (i.e.protected AsyncExecutionService.StatestateThe state.protected IThreadPoolServicethreadpoolThe threadpool.- 
Fields inherited from class jadex.bridge.service.BasicServiceidcnt, impltype, internalaccess, providerid, shutdowned, sid, started, type
 - 
Fields inherited from interface jadex.bridge.service.IServiceEMPTY_SERVICES
 
- 
 - 
Constructor SummaryConstructors Constructor Description AsyncExecutionService(IInternalAccess component)Create a new asynchronous executor service.AsyncExecutionService(IInternalAccess component, java.util.Map<java.lang.String,java.lang.Object> properties)Create a new asynchronous executor service.
 - 
Method SummaryAll 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 in its own thread.IFuture<java.lang.Void>getNextIdleFuture()Get the future indicating that executor is idle.IExecutable[]getRunningTasks()Get the currently running tasks.IFuture<java.lang.Void>shutdownService()Shutdown the executor service.IFuture<java.lang.Void>startService()Start the execution service.- 
Methods inherited from class jadex.bridge.service.BasicServicecreateServiceIdentifier, createServiceIdentifier, equals, generateServiceName, getInterfaceType, getInternalAccess, getInvokeMethod, getMethodInfos, getMethodTimeout, getPropertyMap, getProviderId, getServiceId, hashCode, initNFProperties, invokeMethod, isValid, setComponentAccess, setPropertyMap, setServiceIdentifier, toString
 
- 
 
- 
- 
- 
Field Detail- 
threadpoolprotected IThreadPoolService threadpool The threadpool.
 - 
executorsprotected java.util.Map<IExecutable,Executor> executors The currently waiting tasks (task->executor).
 - 
idlefutureprotected Future<java.lang.Void> idlefuture The idle future.
 - 
stateprotected AsyncExecutionService.State state The state.
 - 
componentprotected IInternalAccess component The component.
 - 
runningexesprotected java.util.Map<IExecutable,Executor> runningexes The running (i.e. non-blocked) executors.
 
- 
 - 
Constructor Detail- 
AsyncExecutionServicepublic AsyncExecutionService(IInternalAccess component) Create a new asynchronous executor service.
 - 
AsyncExecutionServicepublic AsyncExecutionService(IInternalAccess component, java.util.Map<java.lang.String,java.lang.Object> properties) Create a new asynchronous executor service.
 
- 
 - 
Method Detail- 
executepublic void execute(IExecutable task) Execute a task in its own thread.- Specified by:
- executein interface- IExecutionService
- Parameters:
- task- The task to execute. (called from arbitrary threads)
 
 - 
cancelpublic IFuture<java.lang.Void> cancel(IExecutable task) Cancel a task. Triggers the task to be not executed in future.- Specified by:
- cancelin interface- IExecutionService
- Parameters:
- task- The task to execute.
- listener- The listener.
- Returns:
- Future signaling cancellation.
 
 - 
getRunningTaskspublic IExecutable[] getRunningTasks() Get the currently running tasks.- Specified by:
- getRunningTasksin interface- IExecutionService
 
 - 
startServicepublic IFuture<java.lang.Void> startService() Start the execution service. Resumes all scheduled tasks.- Specified by:
- startServicein interface- IInternalService
- Overrides:
- startServicein class- BasicService
- Returns:
- A future that is done when the service has completed starting.
 
 - 
shutdownServicepublic IFuture<java.lang.Void> shutdownService() Shutdown the executor service. // todo: make callable more than once- Specified by:
- shutdownServicein interface- IInternalService
- Overrides:
- shutdownServicein class- BasicService
- Returns:
- A future that is done when the service has completed its shutdown.
 
 - 
customIsValidpublic boolean customIsValid() Test if the service is valid.- Returns:
- True, if service can be used.
 
 - 
getNextIdleFuturepublic IFuture<java.lang.Void> getNextIdleFuture() Get the future indicating that executor is idle.- Specified by:
- getNextIdleFuturein interface- IExecutionService
 
 
- 
 
-