Warning
Features
Retrier
- Pass exception and attempt # to
beforeRetryandafterFailureactions. - Add built-in delay functions for constant, linear, exponential, power, log, and random delays.
- Let users limit
Retrierattempts by total duration, in addition to attempt quantity. - Changed
Retrierfrom using optional parameters to encapsulating them in a struct. - Added optional callback that runs between the failure and the delay before the next attempt, which is nice for logging the intermediate failure.
- Allow async
Retrieroverloads to take options with either synchronous or asynchronous callbacks forIsRetryAllowed,AfterFailure, andBeforeRetrywithout a separate method name (AttemptAsync), allowing async callbacks in sync methods, or forcing those callbacks to always be async, which I tried and causes a warning or extra ugly return statement, takes more lines, prevents one-line expression bodies, and it's too easy to forget and get the sync overload which causes inscrutable bugs because it's not awaiting the func to detect exceptions. Instead, make clever use of an interface hierarchy and some generic type reflection to fix broken method overload resolution (TvsTask<T>).
Fixes
Throttler and Debouncer
- Remove array pooling for argument storage, which was added in 54c2db7, because it uses the same amount of memory (
ConcurrentStacknode objects allocate memory when returning an array to the pool) and takes longer to execute (2.3× – 3.8× as long, depending on how many arguments the func takes). If this causes problems, blame Stephen Toub (https://youtu.be/bw7ljmvbrr0?t=410, https://youtu.be/bw7ljmvbrr0?t=1477). - Statically declare argument array length instead of reflecting it.
- Invoke callback using dynamic language runtime, which is 6–8.3× as fast as CLR reflection's
Delegate.DynamicInvoke.