Polly icon indicating copy to clipboard operation
Polly copied to clipboard

Support for ValueTask

Open blankensteiner opened this issue 3 years ago • 1 comments

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).

blankensteiner avatar Apr 15 '21 10:04 blankensteiner

I've added this to the milestone for v8 for consideration as part of planning whenever work for that version resumes.

martincostello avatar May 06 '21 08:05 martincostello

@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.

martintmk avatar Apr 25 '23 08:04 martintmk

The V8 package released, please try it out.

https://www.nuget.org/packages/Polly.Core/

martintmk avatar Jun 19 '23 10:06 martintmk