问题描述
我刚刚发现微软的功能。最后一个参数是可选的结构,包含以下描述:
Finding this cool, I took a long hard look at the list of functions for both versions of the API. Now, the only other part of the documentation that mentions I/O completion ports is the HttpReceiveHttpRequest
() function. The last parameter is an optional OVERLAPPED
structure with the following description:
没有其他信息,所有结构都是不透明的,故意隐藏连接信息。另请注意,同步和重叠输入和输出主题未提及HTTP API。
There is no other information, and all structures are opaque and deliberately hide connection information. Also notice that the Synchronization and Overlapped Input and Output subject makes no mention of the HTTP API.
有没有人知道如何连接HTTP API的队列到I / O完成端口?
Does anyone have any idea on how to connect the HTTP API's queue to an I/O completion port?
推荐答案
在理论上使用IO完成端口非常简单,但是很容易理解练习:P
Using IO completion ports is trivially simple in theory, but abomnible in practice :P
正常用法是:
- 调用CreateIOCompletionPort到创建一个IO完成端口句柄。
- 创建一堆线程,并在调用GetOverlappedResult时让每个线程循环。当与端口关联的重叠操作完成时,GetOverlappedResult将返回,其中结构指示哪个句柄和操作已完成。
- 在程序运行时,创建它希望异步处理的对象,它通过再次调用CreateIOCompletionPort将每个HANDLE与IO CompletionPort句柄相关联。
现在,每次应用程序发出异步操作时HANDLE(通过传入OVERLAPPED结构信号通知)完成操作的通知将由等待GetOverlappedResult返回的其中一个线程指示。
Now, each time the application issues an asynchronous operation on the HANDLE (which is signalled by passing in an OVERLAPPED struct) the notification of the completed operation will be indicated by one of the threads thats waiting on GetOverlappedResult returning.
明确的含义是由HttpCreateRequestQueue返回的HANDLE可以与IO完成端口关联,后续的异步操作将导致GetOverlappedResult返回操作的结果。
The clear implication is that the HANDLE returned by HttpCreateRequestQueue can be associated with an IO Completion port and subsequent asynchronous operations will result in GetOverlappedResult's returning the result of the operation.
这篇关于将HttpApi与I / O完成端口配合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!