chiark / gitweb /
sd-event: split run into prepare/wait/dispatch
authorTom Gundersen <teg@jklm.no>
Fri, 15 Aug 2014 16:49:29 +0000 (18:49 +0200)
committerTom Gundersen <teg@jklm.no>
Mon, 25 Aug 2014 19:52:36 +0000 (21:52 +0200)
commitc45a5a74465a39280b855f9d720b2ab4779a47fa
treed345eb690e78dbd03093bea93932a2bf87cffac3
parent41a451cc2901a5deb985aea4cc8de204a22e5612
sd-event: split run into prepare/wait/dispatch

This will allow sd-event to be integrated into an external event loop, which
in turn will allow (say) glib-based applications to use our various libraries,
without manually integrating each of them (bus, rtnl, dhcp, ...).

The external event-loop should integrate sd-event int he following way:

Every iteration must start with a call to sd_event_prepare(), which will
return 0 if no event sources are ready to be processed, a positive value if
they are and a negative value on error. sd_event_prepare() may only be called
following sd_event_dispatch(); a call to sd_event_wait() indicating that no
sources are ready to be dispatched; or a failed call to sd_event_dispatch() or
sd_event_wait().

A successful call to sd_event_prepare() indicating that no event sources are
ready to be dispatched must be followed by a call to sd_event_wait(),
which will return 0 if it timed out without event sources being ready to
be processed, a negative value on error and a positive value otherwise.
sd_event_wait() may only be called following a successful call to
sd_event_prepare() indicating that no event sources are ready to be dispatched.

If sd_event_wait() indicates that some events sources are ready to be
dispatched, it must be followed by a call to sd_event_dispatch(). This
is the only time sd_event_dispatch() may be called.
src/libsystemd/sd-event/sd-event.c
src/systemd/sd-event.h