@ParametersAreNonnullByDefault public class ExecutionBuilder extends Object
Used by Tasks.executor(String)
to construct an execution for a given subtask. Can be used to specify whether
the current CallContext
is forked, or if a new one is started. Also one can specify whether and how a given
task might be dropped on system overload conditions.
Most of the time this builder will be used to either call fork(Runnable)
or start(Runnable)
to either fork the current CallContext or to start a sub task with a new one. Also a drop handler can be
supplied using dropOnOverload(Runnable)
to gracefully handle system overload conditions.
Modifier and Type | Method and Description |
---|---|
ExecutionBuilder |
dropOnOverload(Runnable dropHandler)
Specifies that the given task can be dropped (ignored) in system overload conditions, if at least the given
handler is called.
|
Future |
fork(Runnable task)
Specifies to fork the current CallContext while executing the given task.
|
ExecutionBuilder |
frequency(Object synchronizer,
double ticksPerSecond)
Determines the maximal call frequency for tasks scheduled for the given
synchronizer . |
ExecutionBuilder |
minInterval(Object synchronizer,
Duration minimalIntervalDuration)
Determines the minimal interval which has to elapse between two consecutive tasks scheduled for the given
synchronizer . |
Future |
start(Runnable task)
Specifies to create a new CallContext while executing the given task.
|
public Future fork(Runnable task)
task
- the task to execute.Future
representing the execution created by this builder.public Future start(Runnable task)
task
- the task to execute.Future
representing the execution created by this builder.@CheckReturnValue public ExecutionBuilder dropOnOverload(Runnable dropHandler)
dropHandler
- the handler which is informed if the task is dropped due to system overload conditions.public ExecutionBuilder minInterval(Object synchronizer, Duration minimalIntervalDuration)
synchronizer
.
If the execution is requested 'too early' the scheduler will put the task into a queue and defer its execution. If a task for the same synchronizer is deferred already, this task will be dropped completely.
synchronizer
- the object to synchronize onminimalIntervalDuration
- the minimal duration of the intervalpublic ExecutionBuilder frequency(Object synchronizer, double ticksPerSecond)
synchronizer
.
If the execution is requested 'too early' the scheduler will put the task into a queue and defer its execution. If a task for the same synchronizer is deferred already, this task will be dropped completely.
synchronizer
- the object to synchronize onticksPerSecond
- the call frequency in Hertz.Copyright © 2018. All rights reserved.