TIP 3:一个已投递的I/O操作和一个出列的完成通知的关联

来源:互联网 发布:mysql的日期函数 编辑:程序博客网 时间:2024/05/21 11:11
TIP 3: Associate a posted I/O operation with a dequeued completion packet.

GetQueuedCompletionStatus returns a completion key and an overlapped structure for the I/O when dequeuing a completion packet. You should use these two structures to return per handle and per I/O operation information, respectively. You can use your socket handle as the completion key when you register the socket with the IOCP to provide per handle information. To provide per I/O operation "extend" the overlapped structure to contain your application-specific I/O-state information. Also, make sure you provide a unique overlapped structure for each overlapped I/O. When an I/O completes, the same pointer to the overlapped I/O structure is returned.
当一个完成通知出列的时候,GetQueuedCompletionStatus返回了针对这个I/O一个完成键和一个重叠结构,你可以使用两个结构来分别接收返回的单句柄数据和单IO操作数据。当你把某个套接字和IOCP关联,你可以用套接字句柄作为完成键去提供单句柄信息。使用一个扩展的重叠结构其中包含了指定的I/O应用状态信息。区提供单IO操作数据服务。确认你为每一个重叠I/O操作,提供了一个唯一的重叠结构,当一个I/O完成,返回同一个指向重叠IO结构的指针
 
原创粉丝点击