1SD_EVENT_SOURCE_SET_FLOATIsNdG_(e3v)ent_source_set_floSaDt_iEnVgENT_SOURCE_SET_FLOATING(3)
2
3
4

NAME

6       sd_event_source_set_floating, sd_event_source_get_floating - Set or
7       retrieve 'floating' state of event sources
8

SYNOPSIS

10       #include <systemd/sd-event.h>
11
12       int sd_event_source_set_floating(sd_event_source *source,
13                                        int floating);
14
15       int sd_event_source_get_floating(sd_event_source *source);
16

DESCRIPTION

18       sd_event_source_set_floating() takes a boolean and sets the 'floating'
19       state of the specified event source object. This is used to change the
20       direction of reference counts for the object and the event loop it is
21       associated with. In non-floating mode, the event source object holds a
22       reference to the event loop object, but not vice versa. The creator of
23       the event source object must hold a reference to it as long as the
24       source should exist. In floating mode, the event loop holds a reference
25       to the source object, and will decrease the reference count when being
26       freed. This means that a reference to the event loop should be held to
27       prevent both from being destroyed.
28
29       Various calls that allocate event source objects (i.e.
30       sd_event_add_io(3), sd_event_add_time(3) and similar) will
31       automatically set an event source object to 'floating' mode if the
32       caller passed NULL in the parameter used to return a reference to the
33       event source object. Nevertheless, it may be necessary to gain
34       temporary access to the source object, for example to adjust event
35       source properties after allocation (e.g. its priority or description
36       string). In those cases the object may be created in non-floating mode,
37       and the returned reference used to adjust the properties, and the
38       object marked as floating afterwards, and the reference in the caller
39       dropped.
40
41       sd_event_source_get_floating() may be used to query the current
42       'floating' state of the event source object source. It returns zero if
43       'floating' mode is off, positive if it is on.
44

RETURN VALUE

46       On success, sd_event_source_set_floating() and
47       sd_event_source_get_floating() return a non-negative integer. On
48       failure, they return a negative errno-style error code.
49
50   Errors
51       Returned errors may indicate the following problems:
52
53       -EINVAL
54           source is not a valid pointer to an sd_event_source object.
55
56       -ECHILD
57           The event loop has been created in a different process.
58

NOTES

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

SEE ALSO

64       sd-event(3), sd_event_add_io(3), sd_event_add_time(3),
65       sd_event_add_signal(3), sd_event_add_child(3), sd_event_add_inotify(3),
66       sd_event_add_defer(3), sd_event_source_set_description(3),
67       sd_event_source_set_priority(3)
68
69
70
71systemd 253                                    SD_EVENT_SOURCE_SET_FLOATING(3)
Impressum