Add support for SD_EVENT_DEFAULT
authorNathaniel McCallum <npmccallum@redhat.com>
Mon, 22 Jan 2018 20:38:07 +0000 (15:38 -0500)
committerNathaniel McCallum <npmccallum@redhat.com>
Tue, 23 Jan 2018 14:40:25 +0000 (09:40 -0500)
commitb937d761085c484cc1708171c01b9aac37537d4e
tree57f92a60f52a99aa0662bf6057b91bdff51c8608
parente69b29a8b9335a1bebdcdc062945e6a35aac7590
Add support for SD_EVENT_DEFAULT

Currently, sd-event supports the ability to have a thread-local default
event loop. However, this is less useful than it can be since all functions
which require an sd_event* as input require the caller to pass it. This
patch adds a new macro which allows the developer to pass a constant
SD_EVENT_DEFAULT instead. This reduces work for the caller.

For example:

    r = sd_event_default(&e);
    r = sd_event_add_io(e, ...);
    sd_event_unref(e);

Becomes:

    r = sd_event_add_io(SD_EVENT_DEFAULT, ...);

If no thread-local default event loop exists, the function calls will
return -ENOPKG. No event loop will ever be implicitly created.
src/libsystemd/sd-event/sd-event.c
src/systemd/sd-event.h