Tom
Tom

Reputation: 1394

Why GetQueuedCompletionStatus() does not return operation type?

GetQueuedCompletionStatus() dequeue a completion notification, but it does not return what type of notification it is (e.g. Read notification, write notification).

It is my responsibility to keep track of what operations I initiate, for example when I use WSARecv(), I add a flag to the OVERLAPPED structure that indicate what operation this is (read in this case), and when I dequeue a notification, I read this flag. So does anyone knows why GetQueuedCompletionStatus() does not return the type of operation?

Upvotes: 1

Views: 745

Answers (1)

Len Holgate
Len Holgate

Reputation: 21644

Why should it care? You can pass user data through the APIs that result in a completion being extracted via GetQueuedCompletionStatus() so why do you need anything else? Since you can post your own completions using PostQueuedCompletionStatus() there's an infinite number of 'operations' that you could complete, so pass it in the 'extended OVERLAPPED structure and you can pass anything...

If you COULD pass your own separate flag then it wouldn't actually remove the need to pass additional extra stuff as an extended OVERLAPPED structure as it's pretty useful to be able to pass the data buffer and other information along with the operation anyway, so one extra flag is unlikely to be worth having... My designs need more than your designs need, so lets just deal with the method that the API designers gave us...

Upvotes: 1

Related Questions