joyent/libuv — Issue #262: Add asynchronous interface for libuv itself
Author: rmtew
Created: 2011-11-28 11:03:26+00:00
State: open

Currently the control flow for the libuv framework is (as I understand it):

... set up application ...
uv_run()
... return from blocking indefinitely ...

This means that if an application is to use libuv, it needs to let libuv drive it. This affects the way in which the application can be written. If there was a minimal change to the libuv running mechanism to let it be pumped with a specified timeout, then an application could instead drive libuv more in the manner of a library and a main loop could be written in a straight-forward and synchronous manner.

I suggest that this could be done with the following changes:
1. The contents of the while loop in UV_RUN are moved to UV_PUMP.
2. A uv_pump() method is added that takes a optional timeout parameter.
3. The poll method observes the timeout parameter instead of the result of uv_get_poll_timeout(), or perhaps gets it from that function for this pending one-off iteration.

I can write and provide a patch, if there is an indication that one would be applied.

Cheers.