diff options
author | Nathaniel McCallum <npmccallum@redhat.com> | 2018-01-22 15:38:07 -0500 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-05-30 07:50:13 +0200 |
commit | 269ddd6aecc9307853384bfc44a22c9ade596f34 (patch) | |
tree | 83332cac02eded144f14025c409b651a494970f3 /src/systemd | |
parent | 645c13d2553a301820ea8e065f7e1a3e69a489d1 (diff) |
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.
Diffstat (limited to 'src/systemd')
-rw-r--r-- | src/systemd/sd-event.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/systemd/sd-event.h b/src/systemd/sd-event.h index 9083d5fa9..57c1692fc 100644 --- a/src/systemd/sd-event.h +++ b/src/systemd/sd-event.h @@ -40,6 +40,8 @@ _SD_BEGIN_DECLARATIONS; +#define SD_EVENT_DEFAULT ((sd_event *) 1) + typedef struct sd_event sd_event; typedef struct sd_event_source sd_event_source; |