Interface Budget
- All Known Subinterfaces:
IterationBudget,TimeBudget
- All Known Implementing Classes:
IterationBoundedBudget,IterationTimeBoundedBudget,TimeBoundedBudget
public interface Budget
A budget defines how much a task can execute
-
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether the task has budget to continue executing or notelapsed()The amount of time that has elapsed since the budget was created.longDefines an initial delay before running the tasklonginterval()The interval between each task executionbooleannext()Move the task to the next iteration
-
Method Details
-
initialDelay
long initialDelay()Defines an initial delay before running the task- Returns:
- the initial delay, in milliseconds, before running the task
-
interval
long interval()The interval between each task execution- Returns:
- the interval, in milliseconds, for each task execution
-
canContinue
boolean canContinue()Whether the task has budget to continue executing or not- Returns:
- true if the task can continue or false otherwise
-
next
boolean next()Move the task to the next iteration- Returns:
- true if the task can continue or false otherwise
-
elapsed
Duration elapsed()The amount of time that has elapsed since the budget was created. This can be used to account for the amount of time it took to run a task. The precision should be withing a few microseconds/milliseconds due to the start time being created along with the budget instance. We do so to avoid the overhead of checking it the next or canContinue methods because they could be part of the hot path for some components.- Returns:
- The amount of time that has elapsed since the budget was created
-