Class ForegroundTask

java.lang.Object
org.apache.camel.support.task.ForegroundTask
All Implemented Interfaces:
BlockingTask, Task

public class ForegroundTask extends Object implements BlockingTask
Runs a task in the foreground, executing for a given number of iteration and sleeping between each of them.
  • Method Details

    • run

      public boolean run(BooleanSupplier supplier)
      Description copied from interface: BlockingTask
      Run the task
      Specified by:
      run in interface BlockingTask
      Parameters:
      supplier - the task as a boolean supplier. The result is used to check if the task has completed or not. The supplier must return true if the execution has completed or false otherwise.
      Returns:
      true if the task has completed successfully or false if: 1) the budget is exhausted or 2) the task was interrupted.
    • run

      public <T> Optional<T> run(Supplier<T> supplier, Predicate<T> predicate)
      Run a task until it produces a result
      Type Parameters:
      T - the type for the result
      Parameters:
      supplier - the supplier of the result
      predicate - a predicate to test if the result is acceptable
      Returns:
      An optional with the result
    • elapsed

      public Duration elapsed()
      Description copied from interface: Task
      How long it took to run the task
      Specified by:
      elapsed in interface Task
      Returns:
      The duration to execute the task