Package org.jboss.elemento.flow
Class RepeatTask<C extends FlowContext>
java.lang.Object
org.jboss.elemento.flow.RepeatTask<C>
- Type Parameters:
C- the type of the context shared between tasks
- All Implemented Interfaces:
Task<C>
A task implementation that executes a task as long as certain conditions are met.
This implementation makes it easy to nest the execution of asynchronous tasks inside a call to
Flow.parallel(FlowContext, List), Flow.sequential(FlowContext, List) or
Flow.repeat(FlowContext, Task).
-
Constructor Summary
ConstructorsConstructorDescriptionRepeatTask(C context, Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout) RepeatTask(C context, Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout, int iterations) RepeatTask(Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout) RepeatTask(Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout, int iterations) -
Method Summary
-
Constructor Details
-
RepeatTask
public RepeatTask(Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout) Creates a new task that executes the given tasks as long as the given predicate evaluates totrue.The task re-uses the context from the outer call to
Flow.parallel(FlowContext, List),Flow.sequential(FlowContext, List)orFlow.repeat(FlowContext, Task).- Parameters:
task- the task to execute while the predicate evaluates totruepredicate- the predicate used to decide whether to continue or break the loopfailFast- whether the execution of the list should fail fast or fail lastinterval- the interval between the iterationstimeout- the timeout for the while loop
-
RepeatTask
public RepeatTask(Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout, int iterations) Creates a new task that executes the given tasks as long as the given predicate evaluates totrue.The task re-uses the context from the outer call to
Flow.parallel(FlowContext, List),Flow.sequential(FlowContext, List)orFlow.repeat(FlowContext, Task).- Parameters:
task- the task to execute while the predicate evaluates totruepredicate- the predicate used to decide whether to continue or break the loopfailFast- whether the execution of the list should fail fast or fail lastinterval- the interval between the iterationstimeout- the timeout for the while loopiterations- the maximal iterations the loop
-
RepeatTask
public RepeatTask(C context, Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout) Creates a new task that executes the given tasks as long as the given predicate evaluates totrue.The task uses the given context for the execution of the task.
- Parameters:
context- the context shared between the iterationstask- the task to execute while the predicate evaluates totruepredicate- the predicate used to decide whether to continue or break the loopfailFast- whether the execution of the list should fail fast or fail lastinterval- the interval between the iterationstimeout- the timeout for the while loop
-
RepeatTask
public RepeatTask(C context, Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout, int iterations) Creates a new task that executes the given tasks as long as the given predicate evaluates totrue.The task uses the given context for the execution of the task.
- Parameters:
context- the context shared between the iterationstask- the task to execute while the predicate evaluates totruepredicate- the predicate used to decide whether to continue or break the loopfailFast- whether the execution of the list should fail fast or fail lastinterval- the interval between the iterationstimeout- the timeout for the while loopiterations- the maximal iterations the loop
-
-
Method Details
-
apply
Description copied from interface:TaskExecutes the task.- Specified by:
applyin interfaceTask<C extends FlowContext>- Parameters:
context- the context shared between tasks- Returns:
- a promise containing the shared context
-