1SD_EVENT_ADD_DEFER(3)         sd_event_add_defer         SD_EVENT_ADD_DEFER(3)
2
3
4

NAME

6       sd_event_add_defer, sd_event_add_post, sd_event_add_exit,
7       sd_event_handler_t - Add static event sources to an event loop
8

SYNOPSIS

10       #include <systemd/sd-event.h>
11
12       typedef struct sd_event_source sd_event_source;
13
14       typedef int (*sd_event_handler_t)(sd_event_source *s, void *userdata);
15
16       int sd_event_add_defer(sd_event *event, sd_event_source **source,
17                              sd_event_handler_t handler, void *userdata);
18
19       int sd_event_add_post(sd_event *event, sd_event_source **source,
20                             sd_event_handler_t handler, void *userdata);
21
22       int sd_event_add_exit(sd_event *event, sd_event_source **source,
23                             sd_event_handler_t handler, void *userdata);
24

DESCRIPTION

26       These three functions add new static event sources to an event loop.
27       The event loop object is specified in the event parameter, the event
28       source object is returned in the source parameter. The event sources
29       are enabled statically and will "fire" when the event loop is run and
30       the conditions described below are met. The handler function will be
31       passed the userdata pointer, which may be chosen freely by the caller.
32
33       sd_event_add_defer() adds a new event source that will be dispatched
34       instantly, before the event loop goes to sleep again and waits for new
35       events. By default, the handler will be called once (SD_EVENT_ONESHOT).
36       Note that if the event source is set to SD_EVENT_ON the event loop will
37       never go to sleep again, but continuously call the handler, possibly
38       interleaved with other event sources.
39
40       sd_event_add_post() adds a new event source that is run before the
41       event loop will sleep and wait for new events, but only after at least
42       one other non-post event source was dispatched. By default, the source
43       is enabled permanently (SD_EVENT_ON). Note that this event source type
44       will still allow the event loop to go to sleep again, even if set to
45       SD_EVENT_ON, as long as no other event source is ever triggered.
46
47       sd_event_add_exit() adds a new event source that will be dispatched
48       when the event loop is terminated with sd_event_exit(3).
49
50       The sd_event_source_set_enabled(3) function may be used to enable the
51       event source permanently (SD_EVENT_ON) or to make it fire just once
52       (SD_EVENT_ONESHOT).
53
54       If the handler function returns a negative error code, it will be
55       disabled after the invocation, even if the SD_EVENT_ON mode was
56       requested before.
57
58       To destroy an event source object use sd_event_source_unref(3), but
59       note that the event source is only removed from the event loop when all
60       references to the event source are dropped. To make sure an event
61       source does not fire anymore, even when there's still a reference to it
62       kept, consider setting the event source to SD_EVENT_OFF with
63       sd_event_source_set_enabled(3).
64
65       If the second parameter of these functions is passed as NULL no
66       reference to the event source object is returned. In this case the
67       event source is considered "floating", and will be destroyed implicitly
68       when the event loop itself is destroyed.
69

RETURN VALUE

71       On success, these functions return 0 or a positive integer. On failure,
72       they return a negative errno-style error code.
73

ERRORS

75       Returned errors may indicate the following problems:
76
77       -ENOMEM
78           Not enough memory to allocate an object.
79
80       -EINVAL
81           An invalid argument has been passed.
82
83       -ESTALE
84           The event loop is already terminated.
85
86       -ECHILD
87           The event loop has been created in a different process.
88

NOTES

90       These APIs are implemented as a shared library, which can be compiled
91       and linked to with the libsystemd pkg-config(1) file.
92

SEE ALSO

94       systemd(1), sd-event(3), sd_event_new(3), sd_event_now(3),
95       sd_event_add_io(3), sd_event_add_time(3), sd_event_add_signal(3),
96       sd_event_add_child(3), sd_event_add_inotify(3),
97       sd_event_source_set_enabled(3), sd_event_source_set_priority(3),
98       sd_event_source_set_userdata(3), sd_event_source_set_description(3),
99       sd_event_exit(3)
100
101
102
103systemd 239                                              SD_EVENT_ADD_DEFER(3)
Impressum