-
Notifications
You must be signed in to change notification settings - Fork 787
Description
The new "wepoll" strategy is great for sockets but it makes it impossible to use the thread's I/O completion port for other purposes.
I would suggest to add a low-level "plugin" system so that other crates can share the completion port for different purposes.
This could be used for supporting named pipes and files, which can use overlapped I/O but their APIs work differently; more exotic examples are ReadDirectoryChangesW (file change notifications), GetAddrInfoExW (async DNS name lookup), and Job Objects (notifications about child processes).
Job objects in particular are exotic in that windows will send messages to the completion port where lpOverlapped
does not actually point to a struct OVERLAPPED
, but rather contains an indication of the event that happened.
So I would propose to to "switch" based on the lpCompletionKey
value. The most simple solution would be to store a function pointer in it which receives the raw completion information, e.g. fn handle_completion(&OVERLAPPED_ENTRY)
.
To illustrate what I mean, here's a crude prototype: piscisaureus@ac40cd7
Notice how the Selector
is no longer knows anything about Wake
events.
They work simply because the lpCompletionKey
contains an appropriate function pointer