Add Backoff.current to get value without stepping forward.

This commit is contained in:
voussoir 2020-11-20 13:29:33 -08:00
parent 5d83ed655d
commit adc4247efd

View file

@ -24,10 +24,14 @@ class Backoff:
raise ValueError(f'max must be positive, not {max}.') raise ValueError(f'max must be positive, not {max}.')
self.max = max self.max = max
def next(self): def current(self):
y = self._calc() y = self._calc()
if self.max is not None: if self.max is not None:
y = min(y, self.max) y = min(y, self.max)
return y
def next(self):
y = self.current()
self.x += 1 self.x += 1
return y return y