Interface TcpTimeouts.Waiter
- Enclosing interface:
TcpTimeouts
The total wait time starts at 0 and is incremented by each call to getTimeForSleep or sleepTime. Once the total wait time exceeds the maximum total wait time, isExpired returns true.
The timer also has a current wait time, which is returned by getTime and is the interval for which sleep waits. The initial value of the current wait time is get_initial_time_to_wait(). Each subsequent call to advance increases the current wait time by a factor of (previous*get_backoff_factor())/100, unless get_max_single_wait_time is configured and the current wait time exceeds get_max_single_wait_time(). If get_max_single_wait_time() is not used, the current time increases without bound (until it overflows). Once get_max_single_wait_time() is reached, every subsequent call to next() returnes get_max_single_wait_time(), and advance has no effect.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
advance()
Advance to the next timeout value.int
getTime()
Return the current timeout value, but do not increment total wait time.int
Return the current timeout value.boolean
Returns true if the waiter has expired.void
reset()
Set the current timeout back to the initial value.boolean
Sleep for the current timeout value.int
Return the accumulated wait time.
-
Method Details
-
advance
void advance()Advance to the next timeout value. -
reset
void reset()Set the current timeout back to the initial value. Accumulated time is not affected. -
getTimeForSleep
int getTimeForSleep()Return the current timeout value. Also increments total time.- Returns:
- timeout in milliseconds
-
getTime
int getTime()Return the current timeout value, but do not increment total wait time.- Returns:
- timeout in milliseconds
-
timeWaiting
int timeWaiting()Return the accumulated wait time.- Returns:
- time in milliseconds
-
sleepTime
boolean sleepTime()Sleep for the current timeout value. Returns true if sleep happened, otherwise false, in the case where the Waiter has expired.- Returns:
- true if sleep happened
-
isExpired
boolean isExpired()Returns true if the waiter has expired. It expires once the total wait time exceeds get_max_wait_time.- Returns:
- if the waiter has expired
-