Package com.yahoo.time
Class TimeBudget
java.lang.Object
com.yahoo.time.TimeBudget
A TimeBudget can be used to track the time of an ongoing operation, possibly with a timeout.
- Author:
- hakon
-
Method Summary
Modifier and TypeMethodDescriptiondeadline()
Returns the deadline, if present.static TimeBudget
static TimeBudget
Returns a TimeBudget with a start time of now, and with the given timeout.Returns the original timeout, if any.timeLeft()
Returns the time left, possibly negative if the deadline has passed.Returns the time left as a new TimeBudget.Returns the time until deadline, if there is one.Returns time since start.withDeadline
(Instant deadline) Returns a new TimeBudget with the same clock and start, but with this deadline.withReserved
(Duration chunk) Returns a new TimeBudget with the given duration chopped off, reserved for something else.
-
Method Details
-
fromNow
Returns a TimeBudget with a start time of now, and with the given timeout. -
from
-
timePassed
Returns time since start. -
originalTimeout
Returns the original timeout, if any. -
deadline
Returns the deadline, if present. -
timeLeftOrThrow
Returns the time until deadline, if there is one.- Returns:
- time until deadline. It's toMillis() is guaranteed to be positive.
- Throws:
UncheckedTimeoutException
- if the deadline has been reached or passed.
-
timeLeft
Returns the time left, possibly negative if the deadline has passed. -
timeLeftAsTimeBudget
Returns the time left as a new TimeBudget. -
withDeadline
Returns a new TimeBudget with the same clock and start, but with this deadline. -
withReserved
Returns a new TimeBudget with the given duration chopped off, reserved for something else.
-