exposing activecnt

Ryan Dahl ry at tinyclouds.org
Wed Nov 24 10:28:42 CET 2010

On Wed, Nov 24, 2010 at 1:12 AM, Marc Lehmann <schmorp at schmorp.de> wrote:
> On Tue, Nov 23, 2010 at 02:07:39PM -0800, Ryan Dahl <ry at tinyclouds.org> wrote:
>> I would like to have make some actions after ev_loop() drops out due
>> to the ref count going to zero. These actions might setup new watchers
>> or may not. Exposing activecnt will allow me to re-enter ev_loop if
>> the reference count is increased.
> I am really reluctant to expose this. Can you provide a use-case? I can see
> the code, but what does it do that requires this weird construct?
> Before I expose this internal value, I really need to understand what it is
> needed for.

I need a function that runs similar to a ev_prepare watcher, in that
it happens at the end of each iteration. Except I want it to also run
at the end of the last iteration.

In my program I queue up writes throughout the iteration and at the
end I write them to the sockets.  There might be a program that
doesn't set up any watchers, which just wants to write something out -
this does not hit an ev_prepare. If the program queues up a lot to
write out, it may be that while writev-ing this buffer to the socket
it gets a EAGAIN. So it needs to enable a ev_io watcher to wait until
it can finish sending the buffer out.

More information about the libev mailing list