Add uv_overlapped_t for custom IOCP integration (WIP)#1544
Conversation
|
Hi, |
|
Is there anything similar that can be done on Linux? Some kind of |
| @@ -0,0 +1,115 @@ | |||
| /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. | |||
There was a problem hiding this comment.
Quick note: use that copyright text:
Lines 1 to 20 in 1a96fe3
|
@bzoz On Linux there is uv_poll_t which allows detecting when an arbitrary file descriptor is readable or writable, which is enough to integrate many types of I/O including TUN/TAP device. uv_poll_t exists on Windows too but is for sockets only not overlapped operations. |
|
So, can maybe uv_poll_t be extended? I've took a quick look at |
|
Right, this can be merged into
Can the persons with authority please comment on these proposals? Can I expect this feature to be merged? If so, should it be a new handle type as in the current pull request or should it be added to |
|
May be related to #484. We've been wanting something like this for node-serialport for a long time. |
|
@joshperry One should certainly be able to implement serial top on top of uv_overlapped_t. I am using this code for the TAP-Win32 driver and it works without issues. The application code is here: https://github.com/ambrop72/aipstack/tree/master/examples/tap_windows Anyway I think that the architecture of libuv is a bit off in that different handle types are not easily composeable and reused internally. Ideally the core event loop implementation would only provide and know about the primitive event facilities, which are timers and whatever is the native IO notification mechanism on the platform (file descriptor readiness or IOCP). Everything else could be build on top of that (e.g. uv_loop_t shouldn't need to know about tcp, udp, filesystem, etc). |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is my first attempt to add support for integration of arbitrary handles with IOCP (issue #1541). It is slightly different from my initial proposal.
The
uv_overlapped_thandle is used like this:uv_overlapped_get_iocpis used to get the IOCP handle of the event loop.uv_overlapped_get_overlappedis used to get the pointer to theOVERLAPPEDstructure.uv_overlapped_startmust be called after the application has submitted an I/O request (before the event loop next does the polling; else we crash sooner or later). This makes theuv_overlapped_thandle active, anduv_overlapped_startmust not be called again before the callback is invoked.uv_overlapped_thandle becomes inactive and the callback is invoked.uv_closeonuv_overlapped_tbehaves like this:This is currently untested (but compiles).