怎么安全的移除完成端口的key

来源:互联网 发布:网络赌搏 编辑:程序博客网 时间:2024/04/29 23:48
Usually, these are two ways to safe release resource associated with
IOCP.

The first is using refcounting. When issuing a WSARecv/WSASend,
increase
refcount. When GetQueuedCompletionStatus return, decrease refcount.
It is safe to release resouece when refcount is zero.

The second is using a hashtable. For example, pass SocketHandle to
CreateIoCompletionPort as the completion key, and push the pair --
(SocketHandle, Session) -- into hashtable. When
GetQueuedCompletionStatus
return, get the session from the hashtable by the SocketHandle.
When it need to release the session, remove the pair from the
hashtable first.
After that, when GetQueuedCompletionStatus return, it cannot get the
session

from the hashtable any more.


http://alt.winsock.programming.narkive.com/68BFIguM/getqueuedcompletionstatus-when-it-s-safe-to-delete-the-completion-key

0 0
原创粉丝点击