public class Loop extends java.lang.Object implements java.lang.Runnable
steps in an iterative manner as long as the LoopCondition is true.
If no step performs any work in a whole iteration, an IdleStrategy is invoked.| Constructor and Description |
|---|
Loop(LoopCondition loopCondition,
IdleStrategy idleStrategy,
ExceptionHandler exceptionHandler,
Step... steps)
Constructor with loop condition, idle strategy, step exception handler and the steps to perform.
|
| Modifier and Type | Method and Description |
|---|---|
static Loop |
mainLoop(LoopCondition loopCondition,
IdleStrategy idleStrategy,
ExceptionHandler exceptionHandler,
StepProvider... stepProviders)
Static factory method creating a loop with
normal steps using the
given providers to construct the loop steps. |
void |
run() |
static Loop |
shutdownLoop(LoopCondition loopCondition,
IdleStrategy idleStrategy,
ExceptionHandler exceptionHandler,
StepProvider... stepProviders)
Static factory method creating a loop with
shutdown steps using
the given providers to construct the loop steps. |
static StoppableThread |
start(IdleStrategy idleStrategy,
ExceptionHandler exceptionHandler,
java.util.concurrent.ThreadFactory threadFactory,
Step... steps)
Creates, starts and returns a new thread running a loop with the given steps.
|
static ShutdownableThread |
start(IdleStrategy idleStrategy,
ExceptionHandler exceptionHandler,
java.util.concurrent.ThreadFactory threadFactory,
StepProvider... stepProviders)
Creates, starts and returns a new thread running first a main loop and then another shutdown loop during the
graceful
shutdown phase. |
public Loop(LoopCondition loopCondition, IdleStrategy idleStrategy, ExceptionHandler exceptionHandler, Step... steps)
loopCondition - the condition defining when the loop terminatesidleStrategy - the idle strategy defining how to handle situations without work to doexceptionHandler - the handler for step exceptionssteps - the steps executed in the looppublic static Loop mainLoop(LoopCondition loopCondition, IdleStrategy idleStrategy, ExceptionHandler exceptionHandler, StepProvider... stepProviders)
normal steps using the
given providers to construct the loop steps.loopCondition - the condition defining when the loop terminatesidleStrategy - the idle strategy defining how to handle situations without work to doexceptionHandler - the handler for step exceptionsstepProviders - the providers for the steps executed during the looppublic static Loop shutdownLoop(LoopCondition loopCondition, IdleStrategy idleStrategy, ExceptionHandler exceptionHandler, StepProvider... stepProviders)
shutdown steps using
the given providers to construct the loop steps.loopCondition - the condition defining when the loop terminatesidleStrategy - the idle strategy defining how to handle situations without work to doexceptionHandler - the handler for step exceptionsstepProviders - the providers for the steps executed during the looppublic static StoppableThread start(IdleStrategy idleStrategy, ExceptionHandler exceptionHandler, java.util.concurrent.ThreadFactory threadFactory, Step... steps)
idleStrategy - the strategy handling idle loop phasesexceptionHandler - the step exception handlerthreadFactory - the factory to provide the service threadsteps - the steps executed during the looppublic static ShutdownableThread start(IdleStrategy idleStrategy, ExceptionHandler exceptionHandler, java.util.concurrent.ThreadFactory threadFactory, StepProvider... stepProviders)
shutdown phase. The loops are created with steps constructed with
the given providers using normal steps for the main loop and
shutdown steps for the shutdown loop.idleStrategy - the strategy handling idle main loop phasesexceptionHandler - the step exception handlerthreadFactory - the factory to provide the service threadstepProviders - the providers for the steps executed during the looppublic void run()
run in interface java.lang.Runnable