I want to use a thread pool to both initiate/cancel overlapped read operations -- using ReadFile()
and CancelIo()
respectively -- as well as handling any completion port events when read operations complete.
- Any thread can initiate a read operation
- Any thread can handle a read-complete event
- Only the thread that initiated a read may cancel it (this is a
CancelIo()
limitation)
I'm not sure how to implement this. One normally uses GetQueuedCompletionStatus()
to wait on completion port events and WaitOnSingleObject()
to wait on normal events but it's not clear how to mix the two. If PostQueuedCompletionStatus()
would let me specify a specific thread to wake up I'd be set. Any ideas?
UPDATE: The solution must run on Windows XP. Unfortunately this rules out using CancelIoEx()
or GetQueuedCompletionStatusEx()
.