|
This is a pretty close port of `FSTExponentialBackoff`. The changes are pretty minor:
* delay is calculated using <chrono> duration types, not plain numbers, which should be a little more type-safe;
* split a piece of code into a ClampDelay function, because it's reasonably close to std::clamp;
* rephrased the class-level comment to make it clearer that the first attempt always has delay = 0;
* added simple tests (other platforms don't have tests for this).
Also make sure that canceling a DelayedOperation is always valid.
|