.NET 如何使用 IO 线程或 IO 完成端口? [英] How does .NET make use of IO Threads or IO Completion Ports?

查看:46
本文介绍了.NET 如何使用 IO 线程或 IO 完成端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个 .NET 应用程序,它对各种 Web 服务进行多次并发调用,收集它们的响应,然后对这些响应进行一些计算.在尝试获得额外的性能时,我一直在研究通过使用 IO 完成端口来利用 .NET 的 IO 线程的方法的使用.我已经阅读了一些资源,包括 Joe Duffy 最近的书 Concurrent Programming on Windows,虽然我了解"了它们的用处,但我对它们在 .NET 中的行为有点不清楚,我正在寻找一个简洁的解释.

We have a .NET application that makes several concurrent calls to various web services, collects their responses and then makes a few calculations off those responses. In attempting to derive additional performance, I've been investigating the use of approaches that make use of .NET's IO threading via the use of IO completion ports. I've read through several resources including Joe Duffy's recent book Concurrent Programming on Windows and while I "get" their usefulness, I'm a little unclear as to their behavior within .NET and am looking for a concise explanation.

推荐答案

如果您已经在使用异步方法,则可能无需执行任何操作.根据您用于调用 Web 服务的技术,最终,它将下降到 Win32 API 以进行调用以从网络获取字节,为此,它将使用 I/O 完成用于处理异步调用的端口.

Chances are that you don't have to do anything if you are using the asynchronous methods already. Depending on the technology that you are using for the call to the web service, ultimately, it's going to drop down to the Win32 API to make the call to get bytes from the network, and to that end, it will use I/O Completion Ports in order to handle asynchronous calls.

I/O 完成端口背后的基本前提是,在等待 I/O 操作时,有一个线程池在 I/O 操作完成时保持等待(假设您注册使用 I/O 完成端口).当您注册的操作完成时,来自 I/O 完成端口线程池的线程用于处理回调.

The basic premise behind I/O completion ports is that when waiting on I/O operations, there is a thread pool that is kept waiting for when the I/O operations complete (assuming you registered to use I/O completion ports). When your registered operation completes, the thread from the I/O completion port thread pool is used to handle the callback.

当然,在调用 I/O 完成端口后,您的线程可以继续执行更多工作,或者终止,由您选择.

Of course, after calling out to the I/O completion port, your thread can move on to do more work, or terminate, the choice is up to you.

以下应该有助于对其进行更多描述:

The following should help describe it more:

I/O 完成端口:

http://msdn.microsoft.com/en-us/library/aa365198(VS.85).aspx

内部 I/O 完成端口(WayBack 机器):

Inside I/O Completion Ports (WayBack Machine):

https://web.archive.org/web/20101101112358/http://doc.sch130.nsc.ru/www.sysinternals.com/ntw2k/info/comport.shtml

这篇关于.NET 如何使用 IO 线程或 IO 完成端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆