public interface ExecutorService
extends com.google.common.util.concurrent.Service
Modifier and Type | Method and Description |
---|---|
<T> void |
applyBlockingConsumer([logger : Logger],
collection : Iterable<T>,
task : Consumer<? super T>)
Submit a task on the collection's elements to the executor service and wait for the termination of all the tasks.
|
<T> Future<T> |
executeAsap([logger : Logger],
task : Callable<T>)
Submit a task to the executor service.
|
Future<?> |
executeAsap([logger : Logger],
task : Runnable)
Submit a task to the executor service.
|
<T> Future<T> |
executeAsap([logger : Logger],
result : T,
task : Runnable)
Submit a task to the executor service.
|
int |
executeBlockingTask([logger : Logger],
nbExecutions : int,
runGroupSize : int,
task : Runnable)
Submit a single task multiple times to the executor service.
|
void |
executeBlockingTasks([logger : Logger],
[thrownExceptions : boolean],
task : Collection<Runnable>)
Submit tasks to the executor service and wait for the termination of all the tasks.
|
void |
executeNotBlockingTask([logger : Logger],
nbExecutions : int,
runGroupSize : int,
task : Runnable)
Submit a single task multiple times to the executor service.
|
long |
getTaskCount()
Replies the number of tasks that this service has to run.
|
static void |
neverReturn(postCommand : Runnable)
This function simulate the never return from this call.
|
void |
purge()
Remove any canceled/terminated tasks from the lists of tasks.
|
boolean |
remove(task : Runnable)
Removes this task from the executor's internal queue if it is present, thus causing it not to be run
if it has not already started.
|
<T> ScheduledFuture<T> |
schedule([logger : Logger],
[delay : long],
[unit : TimeUnit],
command : Callable<T>)
Schedule the given task.
|
ScheduledFuture<?> |
schedule([logger : Logger],
[delay : long],
[unit : TimeUnit],
command : Runnable)
Schedule the given task.
|
ScheduledFuture<?> |
scheduleAtFixedRate([logger : Logger],
[initialDelay : long],
[period : long],
[unit : TimeUnit],
command : Runnable)
Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the
given period; that is executions will commence after initialDelay then initialDelay+period, then initialDelay + 2 * period,
and so on.
|
ScheduledFuture<?> |
scheduleWithFixedDelay([logger : Logger],
[initialDelay : long],
[delay : long],
[unit : TimeUnit],
command : Runnable)
Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the
given delay between the termination of one execution and the commencement of the next.
|
void |
toJson(buffer : org.arakhne.afc.vmutil.json.JsonBuffer)
Fill the given buffer with the state of the executor service.
|
static def
neverReturn(postCommand : Runnable) : void
ExecutorService
EarlyExitException
is thrown.postCommand
- is the command to be run when the early-exit exception is catch.
This command may be used for running post actions on the same thread as the one which
does an early exit.def
executeAsap([logger : Logger],
task : Runnable) : Future<?>
ExecutorService
According to the implementation of the service, the given task may be run in the same or separated thread than the one of the caller. In another words, there is no warranty that the caller's thread is blocked until the termination of the task.
If an exception occurs into the given task, the exception is logged. It is never thrown by this function.
logger
- the logger to use for errors.task
- the task to submit.if you don't want a future.
def
executeAsap([logger : Logger], result : T, task : Runnable) : Future<T>with
<T>
ExecutorService
According to the implementation of the service, the given task may be run in the same or separated thread than the one of the caller. In another words, there is no warranty that the caller's thread is blocked until the termination of the task.
If an exception occurs into the given task, the exception is logged. It is never thrown by this function.
T
- - the type of the value replied by the task.task
- the task to submit.result
- result to return after the execution.def
executeAsap([logger : Logger], task : Callable<T>) : Future<T>with
<T>
ExecutorService
According to the implementation of the service, the given task may be run in the same or separated thread than the one of the caller. In another words, there is no warranty that the caller's thread is blocked until the termination of the task.
If an exception occurs into the given task, the exception is logged. It is never thrown by this function.
T
- - the type of the value replied by the task.task
- the task to submit.def
schedule([logger : Logger],
[delay : long],
[unit : TimeUnit],
command : Runnable) : ScheduledFuture<?>
ExecutorService
According to the implementation of the service, the given task may be run in the same or separated thread than the one of the caller. In another words, there is no warranty that the caller's thread is blocked until the termination of the task.
If an exception occurs into the given task, the exception is logged. It is never thrown by this function.
logger
- the logger to use for errors.command
- task to rundelay
- delay for waiting before launching the commandunit
- time unit of the delaydef
schedule([logger : Logger], [delay : long], [unit : TimeUnit], command : Callable<T>) : ScheduledFuture<T>with
<T>
ExecutorService
According to the implementation of the service, the given task may be run in the same or separated thread than the one of the caller. In another words, there is no warranty that the caller's thread is blocked until the termination of the task.
If an exception occurs into the given task, the exception is logged. It is never thrown by this function.
T
- - the type of the value replied by the task.logger
- the logger to use for errors.command
- task to rundelay
- delay for waiting before launching the commandunit
- time unit of the delaydef
scheduleAtFixedRate([logger : Logger],
[initialDelay : long],
[period : long],
[unit : TimeUnit],
command : Runnable) : ScheduledFuture<?>
ExecutorService
According to the implementation of the service, the given task may be run in the same or separated thread than the one of the caller. In another words, there is no warranty that the caller's thread is blocked until the termination of the task.
If an exception occurs into the given task, the exception is logged. It is never thrown by this function.
logger
- the logger to use for errors.command
- task to runinitialDelay
- the time to delay first executionperiod
- the period between successive executionsunit
- รจ the time unit of the initialDelay and period parametersdef
scheduleWithFixedDelay([logger : Logger],
[initialDelay : long],
[delay : long],
[unit : TimeUnit],
command : Runnable) : ScheduledFuture<?>
ExecutorService
According to the implementation of the service, the given task may be run in the same or separated thread than the one of the caller. In another words, there is no warranty that the caller's thread is blocked until the termination of the task.
If an exception occurs into the given task, the exception is logged. It is never thrown by this function.
logger
- the logger to use for errors.command
- the task to executeinitialDelay
- the time to delay first executiondelay
- the delay between the termination of one execution and the start of the nextunit
- the time unit of the initialDelay and delay parametersdef
purge() : void
ExecutorService
@Pure
def
getTaskCount() : long
ExecutorService
def
remove(task : Runnable) : boolean
ExecutorService
task
- the task to remove.true
if the task was removed.def
executeBlockingTasks([logger : Logger],
[thrownExceptions : boolean],
task : Collection<Runnable>) : void
ExecutorService
According to the implementation of the service, the given tasks may be run in the same or separated thread than the one of the caller.
If an exception occurs into the given task, the exception is thrown if thrownExceptions
evaluates to true
. If it is evaluates to false
, the exception is logged.
task
- the task to submit.thrownExceptions
- indicates if the exceptions in the given tasks are thrown forward by this function.logger
- the logger to use for errors.def
applyBlockingConsumer([logger : Logger], collection : Iterable<T>, task : Consumer<? super T>) : voidwith
<T>
ExecutorService
You should ensure that the given task is properly synchronized on any shared object.
According to the implementation of the service, the given task may be run in the same or separated thread than the one of the caller.
If an exception occurs into the given consume, the exception is logged and it is thrown.
logger
- the logger to use for errors.collection
- the collection of elements to iterate on.task
- the task to submit. Be sure that the task is synchronized on the given collection.def
executeBlockingTask([logger : Logger],
nbExecutions : int,
runGroupSize : int,
task : Runnable) : int
ExecutorService
The same task instance will be submit to the executor service.
runGroupSize
indicates how many number of times the task will be run on
a single thread.
This function is equivalent to:
for(i in [ 1 .. (nbExecutions/runGroupSize) ])
do
execute({
for(j in [1..runGroupSize]) {
task.run
}
})
done
Caution: if a task
is failing, the exception will be output on the logger. This function never fails.
According to the implementation of the service, the given task may be run in the same or separated thread than the one of the caller.
If an exception occurs into the given consume, the exception is logged. It is never thrown by this function.
logger
- the logger to use for errors.task
- the task to submit.nbExecutions
- the number of times the task must be run, usually greater than 1.runGroupSize
- the number of tasks to be run by a single thread.InterruptedException
- when the function cannot wait for task termination.def
executeNotBlockingTask([logger : Logger],
nbExecutions : int,
runGroupSize : int,
task : Runnable) : void
ExecutorService
The same task instance will be submit to the executor service.
runGroupSize
indicates how many number of times the task will be run on
a single thread.
This function is equivalent to:
for(i in [ 1 .. (nbExecutions/runGroupSize) ])
do
execute({
for(j in [1..runGroupSize]) {
task.run
}
})
done
Caution: if a task
is failing, the exception will be output on the logger. This function never fails.
According to the implementation of the service, the given task may be run in the same or separated thread than the one of the caller.
If an exception occurs into the given consume, the exception is logged. It is never thrown by this function.
logger
- the logger to use for errors.task
- the task to submit.nbExecutions
- the number of times the task must be run, usually greater than 1.runGroupSize
- the number of tasks to be run by a single thread.def
toJson(buffer : org.arakhne.afc.vmutil.json.JsonBuffer) : void
ExecutorService
buffer
- the Json buffer to fill out with the executor service's state.Copyright © 2021 the original authors or authors.