Skip to content

add uv_device_t as stream on windows and Linux to handle device I/O#19

Closed
zhaozg wants to merge 1 commit into
libuv:masterfrom
zhaozg:master
Closed

add uv_device_t as stream on windows and Linux to handle device I/O#19
zhaozg wants to merge 1 commit into
libuv:masterfrom
zhaozg:master

Conversation

@zhaozg

@zhaozg zhaozg commented Nov 29, 2014

Copy link
Copy Markdown
Contributor

After long conversion on joyent/libuv#1580, I need make a RP here.

Libuv is a good i/o framework, and easy to extent, I hope persist on libuv to do my work.

When I want to do r/w device on windows, I try filesystem api, it works for device handle, but not fit my needs. I need a real stream, I try wrap handle as pipe, and fail to work. When I study TTY and TCP, I realize that it not hard to implication a device type stream, because just file operation with overlapped, even simpler than other stream types.

There are only two type related api.

UV_EXTERN int uv_device_init(uv_loop_t* handle,
                                    uv_device_t* device,  
                                    const char* path, 
                                    int flags);
UV_EXTERN int uv_device_ioctl(uv_device_t* device, int cmd, uv_ioargs_t* args);

uv_device_init will init and create a uv_deive_t, path should be '/dev/??' on linux or ".\Global???" on windows. flags should be O_RDONLY,O_WRONLY or O_RDWR.

uv_device_ioctl will set or get device paramater, arg is relative with OS platform, return >=0 for success, detail please see header file.

because not test widely, so maybe have bugs, please attention.

Happy for do something for libUV.

@saghul

saghul commented Dec 1, 2014

Copy link
Copy Markdown
Member

Thanks for reopening the PR @zhaozg I'll take a look as soon as I can.

@leearmstrong

Copy link
Copy Markdown

Really want this PR merged in to stop appalling performance on low CPU devices

@Ralith

Ralith commented Apr 8, 2015

Copy link
Copy Markdown
Contributor

What advantage does this have over just using uv_poll?

@saghul

saghul commented Apr 8, 2015

Copy link
Copy Markdown
Member

@Ralith uv_poll only works for sockes on Windows. Also, IIRC it wouldn't work on OSX either.

@zhaozg

zhaozg commented May 30, 2015

Copy link
Copy Markdown
Contributor Author

rebase with master, please see #378

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants