Uh oh!
There was an error while loading. Please reload this page.
Small optimizations in System.Net.NetworkInformation - #64423
Conversation
ghost
commented
Jan 28, 2022
Tagging subscribers to this area: @dotnet/ncl Issue DetailsThis PR does two small optimizations:
|
stephentoub
commented
Jan 28, 2022
Thanks. It's fine to change the |
teo-tsirpanis
commented
Jan 28, 2022
Done @stephentoub. Can you tell me more about this debugger limitation with |
stephentoub
commented
Jan 28, 2022
Debuggers know about the built-in work item types. They know about their layout, what their fields mean, etc. An arbitrary IThreadPoolWorkItem is an unknown entity. They can't reason about what it is, what it represents, etc. |
# Use non-generic TaskCompletionSource Use the non-generic `TaskCompletionSource` where appropriate. ## Description Inspired by dotnet/runtime#64423, I had a look to see if there were any usages of `TaskCompletionSource<T>` that could just use the non generic variant instead. Searching for `bool`, `int` and `object` I found quite a few, mostly in tests, which were just being used to signal completion of arbitrary operation where the `T` value wasn't used. This PR changes all such usages that wouldn't require use of conditional compilation to handle TFMs that don't have support for `TaskCompletionSource`.
This PR does two small optimizations:
In theTeredoHelperclass, we used to queue a callback to the thread pool by using the good oldThreadPool.QueueUserWorkItemmethod. I changed it by implementing theIThreadPoolWorkIteminterface inTeredoHelper, and queueing it directly to the thread pool, saving an allocation, and avoiding needlessly flowing theExecutionContext(judging from the nameTeredoHelper.UnsafeNotifyStableUnicastIpAddressTable).SystemIPGlobalProperties.GetUnicastAddressesAsyncwas creating aTaskCompletionSource<bool>, while the newer non-genericTaskCompletionSourceclass is more appropriate and has a tiny bit smaller footprint. I changed it.