gpt4 book ai didi

c# - 我在哪里/如何找到 .net 类是否使用 IOCP?

转载 作者:IT王子 更新时间:2023-10-29 04:42:03 24 4
gpt4 key购买 nike

更新

我问错了问题,改写了(基于关于答案和评论的重要信息):

是否有关于 .net 的异步操作是真正的异步,因此是 IOCP 还是异步(重叠)的任何好的来源?是否有任何快速的方法来查明是否有多个类正在这样做? p>

Example of not trusting framework developers blindly

The natural starting point for creating a FileStream is the static File.Open() method, the documentation for which mentions nothing about synchronicity of the FileStream that is created! Nor does it allow you to provide FileOptions (which are used to specify the magic FileOptions.Asynchronous flag).

Instead, the FileStream is created with FileOptions.None. Any asynchronous operations are quietly faked by the obliging implementation of the Stream base class, which merely wraps the corresponding synchronous method in a delegate and invokes it on the thread pool using the BeginInvoke() method.

This is a deviation from the usual ‘pit of success’ design philosophy, where everything in .NET seems to work as you think it would, without a need to closely read the documentation and/or gradually discover obscure catches and gotchas over time.


我一直在尝试查找有关在 .NET 中使用IO 完成端口 的信息。

有什么好的方法可以知道给定的 .NET 类是否正在使用 IO 完成端口? (无需在每次使用新类时都运行一些测试。

我尝试了一些类和方法的 msdn 文档,但我找不到任何内容。

如果有一些使用 IOCP 的类列表,那就更好了。

最佳答案

I/O 完成端口是一个强大的平台实现细节,.NET 不能盲目依赖它来提供。事实并非如此,它由 CLR 主机来实现对操作系统支持的粘合。底层托管接口(interface)是 IHostIoCompletionManager , 从 .NET 2.0 开始可用

因此,如果您想要严格保证它们确实被使用,那么您需要获取您使用的 CLR 主机的源代码。这很难获得,有很多,您需要申请 Microsoft 的工作才能访问源代码。源代码中只有 SSCLI20 主机可用,它已过时并且仅涵盖默认主机。它本身经过调整以允许 PAL 提供 I/O 完成端口,这肯定不会实际出现在您曾经运行过的真实 CLR 主机中。

您没有具体说明您考虑的平台是什么。一些猜测:

  • ASP.NET:是的,I/O 完成端口对套接字来说很重要
  • SQL Server:很有可能,但不是 slamdunk,它有以不同方式做事的诀窍
  • 桌面:是的,对于在 NT 分支上运行的任何 .NET 版本 >= 2.0
  • 紧凑型:绝对不是
  • 微:绝对不是
  • Xbox:不太可能,操作系统细节是个大谜
  • Silverlight:Windows 版本的 CoreCLR.dll 使用它但没有使用 ThreadPool.BindHandle
  • Phone7:类似于Silverlight
  • Phone8:可能是个大谜。

强调这些只是有根据的猜测,没有证据支持。这个问题在其他方面相当奇怪,如果您发现异步 I/O 是由重叠 I/O 完成的,您就没有其他选择了。

关于c# - 我在哪里/如何找到 .net 类是否使用 IOCP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21439390/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com