Polly
Polly copied to clipboard
Support for ValueTask
Hi
Any plans for adding support for ValueTask?
Adding: ValueTask ExecuteAsync(Func<ValueTask> action); and so on to IAsyncPolicy.
I know you could just ".AsTask()" the ValueTask, but that sort of defeats the whole purpose of ValueTask.
For targets that don't include ValueTask (.NET Framework 4.6.1 and .NET Standard 2.0), it can be added via the Microsoft.Bcl.AsyncInterfaces NuGet packages. This means that Polly support for .NET Standard 1.1 has to be dropped, but maybe that time has come? Could be something to think about for the next major release (8.0).
I've added this to the milestone for v8 for consideration as part of planning whenever work for that version resumes.
@blankensteiner
The v8 has native support for value tasks and much better performance.
See: https://github.com/App-vNext/Polly/blob/a1ef1bb54c9aabd95b684d4c5cfde6dfc693a5ae/src/Polly.Core/ResilienceStrategy.Async.ValueTaskT.cs#L14
This issue will be closed once v8 releases.
The V8 package released, please try it out.
https://www.nuget.org/packages/Polly.Core/