Debian Codegraph @

upstream/debian-unstable/man3/sd_event_source_set_floating.3

raw
1 '\" t
2 .TH "SD_EVENT_SOURCE_SET_FLOATING" "3" "" "systemd 261~rc3" "sd_event_source_set_floating"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 sd_event_source_set_floating, sd_event_source_get_floating \- Set or retrieve \*(Aqfloating\*(Aq state of event sources
24 .SH "SYNOPSIS"
25 .sp
26 .ft B
27 .nf
28 #include <systemd/sd\-event\&.h>
29 .fi
30 .ft
31 .HP \w'int\ sd_event_source_set_floating('u
32 .BI "int sd_event_source_set_floating(sd_event_source\ *" "source" ", int\ " "floating" ");"
33 .HP \w'int\ sd_event_source_get_floating('u
34 .BI "int sd_event_source_get_floating(sd_event_source\ *" "source" ");"
35 .SH "DESCRIPTION"
36 .PP
37 \fBsd_event_source_set_floating()\fR
38 takes a boolean and sets the \*(Aqfloating\*(Aq state of the specified event source object\&. This is used to change the direction of reference counts for the object and the event loop it is associated with\&. In non\-floating mode, the event source object holds a reference to the event loop object, but not vice versa\&. The creator of the event source object must hold a reference to it as long as the source should exist\&. In floating mode, the event loop holds a reference to the source object, and will decrease the reference count when being freed\&. This means that a reference to the event loop should be held to prevent both from being destroyed\&.
39 .PP
40 Various calls that allocate event source objects (i\&.e\&.
41 \fBsd_event_add_io\fR(3),
42 \fBsd_event_add_time\fR(3)
43 and similar) will automatically set an event source object to \*(Aqfloating\*(Aq mode if the caller passed
44 \fBNULL\fR
45 in the parameter used to return a reference to the event source object\&. Nevertheless, it may be necessary to gain temporary access to the source object, for example to adjust event source properties after allocation (e\&.g\&. its priority or description string)\&. In those cases the object may be created in non\-floating mode, and the returned reference used to adjust the properties, and the object marked as floating afterwards, and the reference in the caller dropped\&.
46 .PP
47 \fBsd_event_source_get_floating()\fR
48 may be used to query the current \*(Aqfloating\*(Aq state of the event source object
49 \fIsource\fR\&. It returns zero if \*(Aqfloating\*(Aq mode is off, positive if it is on\&.
50 .SH "RETURN VALUE"
51 .PP
52 On success,
53 \fBsd_event_source_set_floating()\fR
54 and
55 \fBsd_event_source_get_floating()\fR
56 return a non\-negative integer\&. On failure, they return a negative errno\-style error code\&.
57 .SS "Errors"
58 .PP
59 Returned errors may indicate the following problems:
60 .PP
61 \fB\-EINVAL\fR
62 .RS 4
63 \fIsource\fR
64 is not a valid pointer to an
65 sd_event_source
66 object\&.
67 .sp
68 Added in version 244\&.
69 .RE
70 .PP
71 \fB\-ECHILD\fR
72 .RS 4
73 The event loop has been created in a different process, library or module instance\&.
74 .sp
75 Added in version 244\&.
76 .RE
77 .SH "NOTES"
78 .PP
79 Functions described here are available as a shared library, which can be compiled against and linked to with the
80 \fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
81 file\&.
82 .PP
83 The code described here uses
84 \fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call
85 \fBsetenv\fR(3)
86 from a parallel thread\&. It is recommended to only do calls to
87 \fBsetenv()\fR
88 from an early phase of the program when no other threads have been started\&.
89 .SH "HISTORY"
90 .PP
91 \fBsd_event_source_set_floating()\fR
92 and
93 \fBsd_event_source_get_floating()\fR
94 were added in version 244\&.
95 .SH "SEE ALSO"
96 .PP
97 \fBsd-event\fR(3), \fBsd_event_add_io\fR(3), \fBsd_event_add_time\fR(3), \fBsd_event_add_signal\fR(3), \fBsd_event_add_child\fR(3), \fBsd_event_add_inotify\fR(3), \fBsd_event_add_defer\fR(3), \fBsd_event_source_set_description\fR(3), \fBsd_event_source_set_priority\fR(3)