Skip to content
Discussion options

You must be logged in to vote

Are all the struct-based benefits moot?

It depends on the scenario.

First, if you're targeting a runtime that doesn't support runtime async, e.g. you're publishing a netstandard library, ValueTask still has all the benefits it previously did.

Second, there are important places where ValueTask is wrapping a customized IValueTaskSource, for example in Socket, which caches a singleton IValueTaskSource for reads and another for writes, making the majority use case with sockets ammortized allocation free.

Third, runtime async helps primarily in the (very common) case where the consumer is directly consuming the task returned from the callee via await, but that's not always the case. ValueTas…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by RenderMichael
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants