X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=man%2Fsd_event_new.xml;h=ddb8dac5a50ad54090d96acbe08fcb9ddf6f6f48;hb=8d4798e82138a55336cfb2ec1a661639da5829af;hp=d392ed30b0a67e867303f2a2cf0aa99ddbcb44a4;hpb=8474b70c3a3842cdf3d51f331dd117ab6421f6d0;p=thirdparty%2Fsystemd.git diff --git a/man/sd_event_new.xml b/man/sd_event_new.xml index d392ed30b0a..ddb8dac5a50 100644 --- a/man/sd_event_new.xml +++ b/man/sd_event_new.xml @@ -1,40 +1,16 @@ - + - + sd_event_new systemd - - - - Developer - Lennart - Poettering - lennart@poettering.net - - @@ -47,32 +23,48 @@ along with systemd; If not, see . sd_event_default sd_event_ref sd_event_unref + sd_event_unrefp + sd_event_get_tid + sd_event Acquire and release an event loop object - #include <systemd/sd-bus.h> + #include <systemd/sd-event.h> + + typedef struct sd_event sd_event; int sd_event_new - sd_bus **event + sd_event **event int sd_event_default - sd_bus **event + sd_event **event + + + + sd_event *sd_event_ref + sd_event *event + + + + sd_event *sd_event_unref + sd_event *event - sd_bus *sd_event_ref - sd_bus *event + void sd_event_unrefp + sd_event **event - sd_bus *sd_event_unref - sd_bus *event + int sd_event_get_tid + sd_event *event + pid_t *tid @@ -103,6 +95,19 @@ along with systemd; If not, see . thread. All threads have exactly either zero or one default event loop objects associated, but never more. + After allocating an event loop object, add event sources to + it with + sd_event_add_io3, + sd_event_add_time3, + sd_event_add_signal3, + sd_event_add_child3, + sd_event_add_inotify3, + sd_event_add_defer3, + sd_event_add_post3 or + sd_event_add_exit3, + and then execute the event loop using + sd_event_loop3. + sd_event_ref() increases the reference count of the specified event loop object by one. @@ -114,16 +119,51 @@ along with systemd; If not, see . sd_event_default(), then releasing it, and then acquiring a new one with sd_event_default() will result in two - distinct objects. Note that in order to free an event loop object, + distinct objects. Note that, in order to free an event loop object, all remaining event sources of the event loop also need to be freed as each keeps a reference to it. + + sd_event_unrefp() is similar to + sd_event_unref() but takes a pointer to a + pointer to an sd_event object. This call is useful in + conjunction with GCC's and LLVM's Clean-up + Variable Attribute. Note that this function is defined as + inline function. Use a declaration like the following, + in order to allocate an event loop object that is freed + automatically as the code block is left: + + { + __attribute__((cleanup(sd_event_unrefp)) sd_event *event = NULL; + int r; + … + r = sd_event_default(&event); + if (r < 0) + fprintf(stderr, "Failed to allocate event loop: %s\n", strerror(-r)); + … +} + + sd_event_ref(), + sd_event_unref() and + sd_event_unrefp() execute no operation if the + passed in event loop object is NULL. + + sd_event_get_tid() retrieves the thread + identifier ("TID") of the thread the specified event loop object + is associated with. This call is only supported for event loops + allocated with sd_event_default(), and + returns the identifier for the thread the event loop is the + default event loop of. See gettid2 + for more information on thread identifiers. Return Value - On success, sd_event_new() and - sd_event_default() return 0 or a positive + On success, sd_event_new(), + sd_event_default() and + sd_event_get_tid() return 0 or a positive integer. On failure, they return a negative errno-style error code. sd_event_ref() always returns a pointer to the event loop object passed @@ -149,19 +189,20 @@ along with systemd; If not, see . The maximum number of event loops has been allocated. - - - - Notes + + -ENXIO + + sd_event_get_tid() was + invoked on an event loop object that was not allocated with + sd_event_default(). + - sd_event_new() and the other functions - described here are available as a shared library, which can be - compiled and linked to with the - libsystemd pkg-config1 - file. + + + See Also @@ -172,9 +213,10 @@ along with systemd; If not, see . sd_event_add_time3, sd_event_add_signal3, sd_event_add_child3, + sd_event_add_inotify3, sd_event_add_defer3, - sd_event_add_post3, - sd_event_add_exit3 + sd_event_run3, + gettid2