Am 21.09.2014 19:29, schrieb Luís Marques:

On Sun, 21 Sep 2014 18:17:04 +0200, Sönke Ludwig wrote:

It uses the event loop implementation specific mechanism - for libevent
that is event_base_loopbreak and for Win32 it's a WM_QUIT message.

What I don't exactly understand is why can't we also use that mechanism for the "temporary implicit event loop for each blocking operation"?

Is it because vibed does not have a reference to those event loops?
Is it because if we quit one temporary event loop we would just continue to the next one, once we reach the next blocking operation in the module ctor?

More the latter, and even on a lower level. For example a socket read is
usually implemented similar to this:

while (bytes_read < bytes_to_read) {
     if (!try_to_read_some_bytes(&bytes_read))
         wait_for_socket_to_become_ready();
}

Now in the non-event-loop case, the wait function would simply run such
a temporary loop (instead if yield()ing). But when this loop gets
terminated, it would simply go to the next while loop iteration and
would wait again. So in the end wait would have to throw an
exception to not cause strange effects within the normal program flow.