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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
canContinue()
Whether the task has budget to continue executing or notDuration
elapsed()
The amount of time that has elapsed since the budget was created.long
initialDelay()
Defines an initial delay before running the tasklong
interval()
The interval between each task executionboolean
next()
Move the task to the next iteration
-
-
-
Method Detail
-
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
-
-