chiark / gitweb /
Add support for SD_EVENT_DEFAULT
authorNathaniel McCallum <npmccallum@redhat.com>
Mon, 22 Jan 2018 20:38:07 +0000 (15:38 -0500)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:50:13 +0000 (07:50 +0200)
commit269ddd6aecc9307853384bfc44a22c9ade596f34
tree83332cac02eded144f14025c409b651a494970f3
parent645c13d2553a301820ea8e065f7e1a3e69a489d1
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/libelogind/sd-event/sd-event.c
src/systemd/sd-event.h