6 ms·
The C# version will copy the list into an array during Task.WhenAll, it may save some memory to use an array directly. Souce: https://github.com/microsoft/refe
by 0xcoffee 2y ago
The C# version will copy the list into an array during Task.WhenAll, it may save some memory to use an array directly.
Souce: https://github.com/microsoft/referencesource/blob/master/mscorlib/system/threading/Tasks/Task.cs#L5998 https://github.com/microsoft/referencesource/blob/master/msc...
- neonsunset 2y agoIt doesn't take that much space, and not all languages have option to easily map an initial range onto an iterator that produces tasks. Most are dominated by the size of state machines/virtual threads. Please note that the link above leads to old code from .NET Framework. The up-to-date .NET implementation lives here: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs#L5933-L6489 https://github.com/dotnet/runtime/blob/main/src/libraries/Sy...
- MarkSweep 2y agoThe referencesource repository is only relevant if you are using the legacy .NET Framework. Modern .NET has a special case for passing a List<Task> and avoids the allocation: https://github.com/dotnet/runtime/blob/1f01bee2a41e0df97089fe083c09c59401437b49/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs#L5947 https://github.com/dotnet/runtime/blob/1f01bee2a41e0df97089f...
- deleted 2y ago[deleted]