looking for an example of libuv embedded in libevent
270 views
Skip to first unread message
Ramesh Rayaprolu
unread,
Jan 22, 2014, 7:51:46 PM1/22/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to li...@googlegroups.com
I am trying to do async File IO using libuv (uv_fs_* api's).
I need to embed this File IO into an application which uses libevent and has its own main-loop.
I was looking for such examples, and did not find any. Please let me know if someone has it.
The problem that I am facing is like this -- uv_fs_open, uv_fs_read have their own callbacks (which use uv_fs_t * as argument). But libevent has its own callback and that call back cannot get this "uv_fs_t *"
So, whenever I add the uv_backend_fd to libevent, and as soon as I do uv_fs_open, I reach the libevent callback, and I see that the uv_fs_t * is not yet updated. Thus , I cannot get the uv_file (fd) to further read/write on this.
Any help or suggestions on this is greatly appreciated.
Thanks and Best Regards, Ramesh
Fedor Indutny
unread,
Jan 23, 2014, 2:49:17 AM1/23/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to li...@googlegroups.com
Hello!
You may want to try following scenario:
1. Adding uv_backend_fd() to the libevent's loop
2. On change on that fd do: uv_run(UV_RUN_NOWAIT)
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to li...@googlegroups.com
This isn't using the recommend backend kqueue method but here is an example I created to use the threadpool behavior, you may be able to adopt it to your needs - see attached.