Package cz.xtf.core.waiting.failfast
Class ExponentialTimeBackoff
- java.lang.Object
-
- cz.xtf.core.waiting.failfast.ExponentialTimeBackoff
-
public class ExponentialTimeBackoff extends Object
Class provide support for exponential time backoff. This is convenient if you need to check some event periodically. The class providesnextmethod that implements wait (blocking or non-blocking - returns true/false whether code can proceed).Class wait time grow exponentially up to
maxBackoffMillistime: 1sec, 2 sec, 4 sec, 8 sec,...,maxBackoffMillis.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExponentialTimeBackoff.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ExponentialTimeBackoff.Builderbuilder()booleannext()Exponential backoff wait.
-
-
-
Method Detail
-
builder
public static ExponentialTimeBackoff.Builder builder()
-
next
public boolean next()
Exponential backoff wait. If wait is blocking,Thread.sleep(long)is called and true is always returned. If wait is non-blocking, the method returns true if logic can proceed (enough time has elapsed)- Returns:
- true if logic can proceed
-
-