Greetings, knights of libev. I'm part of the node.js dev community and are working on a library version of node (which can be embedded in other programs). Many "host" systems already use a runloop system of their own (e.g. OS X applications use something called CFRunLoop) thus there's a need to have node running in symbios with these systems.
For this to work smoothly there's some information related to a libev
runloop which is not exposed through the API. We added the following
four functions:
• ev_backend_fd -- ability to acquire the FD used by the backend (e.g.
to register for events so the parent runloop can yield for libev when
appropriate).
• ev_refcount -- ability to know the number of active events, so the
runloop iteration invocation can be optimized.
• ev_loop_fdchangecount -- ability to know when to stop yielding for libev
• ev_loop_next_waittime -- ability to know when to next invoke ev_loop.
In our current implementation, we call the following function when
needed (either because backend FD has pending changes or waittime
passed):
void NodeLoopIteration() {
ev_now_update();
ev_loop(EV_DEFAULT_UC_ EVLOOP_NONBLOCK);
while(ev_loop_fdchangecount() != 0) {
ev_loop(EV_DEFAULT_UC_ EVLOOP_NONBLOCK);
}
}
I've attached the patch we created. It's very rudimentary and the only
real code (ev_loop_next_waittime) is copy-pasted from ev_loop.
Would really appreciate this patch being integrated!
Thank you.
--
Rasmus Andersson
libev.patch
Description: Binary data
_______________________________________________ libev mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
