Package jadex.commons.concurrent
Class LoadManagingExecutionService
- java.lang.Object
-
- jadex.commons.concurrent.LoadManagingExecutionService
-
public class LoadManagingExecutionService extends java.lang.Object
This class allows to perform background operations with adjustable CPU utilization.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
LoadManagingExecutionService.Task
A task info holds a task and meta information.
-
Field Summary
Fields Modifier and Type Field Description protected int
concurrency
The number of currently running tasks.protected static int
COUNTER
The counter.protected Executor
executor
The executor for performing management operations.protected int
limit
A limit for concurrency (to avoid exceeding the timeslice).protected double
load
The desired CPU load.protected IThreadPool
pool
The thread pool.protected long
start
The last start time.protected java.util.Set
tasks
The tasks to do.protected long
timeslice
The max time slice (in ms).
-
Constructor Summary
Constructors Constructor Description LoadManagingExecutionService(IThreadPool pool)
Create an execution service with default settings (timeslice=50).LoadManagingExecutionService(IThreadPool threadpool, long timeslice)
Create an execution service with given settings.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(IExecutable executable, double priority)
Execute a task.static void
main(java.lang.String[] args)
protected void
taskPerformed(LoadManagingExecutionService.Task task)
Called when a task has been performed once.
-
-
-
Field Detail
-
pool
protected IThreadPool pool
The thread pool.
-
load
protected double load
The desired CPU load.
-
timeslice
protected long timeslice
The max time slice (in ms). Only met if single tasks are below this time.
-
tasks
protected java.util.Set tasks
The tasks to do.
-
executor
protected Executor executor
The executor for performing management operations.
-
limit
protected int limit
A limit for concurrency (to avoid exceeding the timeslice).
-
start
protected long start
The last start time.
-
concurrency
protected int concurrency
The number of currently running tasks.
-
COUNTER
protected static int COUNTER
The counter.
-
-
Constructor Detail
-
LoadManagingExecutionService
public LoadManagingExecutionService(IThreadPool pool)
Create an execution service with default settings (timeslice=50).
-
LoadManagingExecutionService
public LoadManagingExecutionService(IThreadPool threadpool, long timeslice)
Create an execution service with given settings.
-
-
Method Detail
-
execute
public void execute(IExecutable executable, double priority)
Execute a task. Triggers the task to be executed in future.- Parameters:
executable
- The task to execute.listener
- Called when execution has started.
-
taskPerformed
protected void taskPerformed(LoadManagingExecutionService.Task task)
Called when a task has been performed once.
-
main
public static void main(java.lang.String[] args)
-
-