summaryrefslogtreecommitdiffstats
path: root/upstream/debian-unstable/man3/sd_event_source_unref.3
blob: 53b7a609b4889b3f07e651cf10928f7fe6e5adc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
'\" t
.TH "SD_EVENT_SOURCE_UNREF" "3" "" "systemd 256~rc3" "sd_event_source_unref"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
sd_event_source_unref, sd_event_source_unrefp, sd_event_source_ref, sd_event_source_disable_unref, sd_event_source_disable_unrefp \- Increase or decrease event source reference counters
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include <systemd/sd\-event\&.h>
.fi
.ft
.HP \w'sd_event_source*\ sd_event_source_unref('u
.BI "sd_event_source* sd_event_source_unref(sd_event_source\ *" "source" ");"
.HP \w'void\ sd_event_source_unrefp('u
.BI "void sd_event_source_unrefp(sd_event_source\ **" "source" ");"
.HP \w'sd_event_source*\ sd_event_source_ref('u
.BI "sd_event_source* sd_event_source_ref(sd_event_source\ *" "source" ");"
.HP \w'sd_event_source*\ sd_event_source_disable_unref('u
.BI "sd_event_source* sd_event_source_disable_unref(sd_event_source\ *" "source" ");"
.HP \w'void\ sd_event_source_disable_unrefp('u
.BI "void sd_event_source_disable_unrefp(sd_event_source\ **" "source" ");"
.SH "DESCRIPTION"
.PP
\fBsd_event_source_unref()\fR
may be used to decrement by one the internal reference counter of the event source object specified as
\fIsource\fR\&. The reference counter is initially set to one, when the event source is created with calls such as
\fBsd_event_add_io\fR(3)
or
\fBsd_event_add_time\fR(3)\&. When the reference counter reaches zero, the object is detached from the event loop object and destroyed\&.
.PP
\fBsd_event_source_unrefp()\fR
is similar to
\fBsd_event_source_unref()\fR
but takes a pointer to a pointer to an
\fBsd_event_source\fR
object\&. This call is useful in conjunction with GCC\*(Aqs and LLVM\*(Aqs
\m[blue]\fBClean\-up Variable Attribute\fR\m[]\&\s-2\u[1]\d\s+2\&. Note that this function is defined as inline function\&.
.PP
\fBsd_event_source_ref()\fR
may be used to increase by one the internal reference counter of the event source object specified as
\fIsource\fR\&.
.PP
\fBsd_event_source_unref()\fR,
\fBsd_bus_creds_unrefp()\fR
and
\fBsd_bus_creds_ref()\fR
execute no operation if the passed event source object is
\fBNULL\fR\&.
.PP
Note that event source objects stay alive and may be dispatched as long as they have a reference counter greater than zero\&. In order to drop a reference of an event source and make sure the associated event source handler function is not called anymore it is recommended to combine a call of
\fBsd_event_source_unref()\fR
with a prior call to
\fBsd_event_source_set_enabled()\fR
with
\fBSD_EVENT_OFF\fR
or call
\fBsd_event_source_disable_unref()\fR, see below\&.
.PP
\fBsd_event_source_disable_unref()\fR
combines a call to
\fBsd_event_source_set_enabled()\fR
with
\fBSD_EVENT_OFF\fR
with
\fBsd_event_source_unref()\fR\&. This ensures that the source is disabled before the local reference to it is lost\&. The
\fIsource\fR
parameter is allowed to be
\fBNULL\fR\&.
.PP
\fBsd_event_source_disable_unrefp()\fR
is similar to
\fBsd_event_source_unrefp()\fR, but in addition disables the source first\&. This call is useful in conjunction with GCC\*(Aqs and LLVM\*(Aqs
\m[blue]\fBClean\-up Variable Attribute\fR\m[]\&\s-2\u[1]\d\s+2\&. Note that this function is defined as inline function\&.
.SH "RETURN VALUE"
.PP
\fBsd_event_source_unref()\fR
and
\fBsd_event_source_disable_unref()\fR
always return
\fBNULL\fR\&.
\fBsd_event_source_ref()\fR
always returns the event source object passed in\&.
.SH "NOTES"
.PP
Functions described here are available as a shared library, which can be compiled against and linked to with the
\fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
file\&.
.PP
The code described here uses
\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
\fBsetenv\fR(3)
from a parallel thread\&. It is recommended to only do calls to
\fBsetenv()\fR
from an early phase of the program when no other threads have been started\&.
.SH "HISTORY"
.PP
\fBsd_event_source_unref()\fR,
\fBsd_event_source_unrefp()\fR, and
\fBsd_event_source_ref()\fR
were added in version 229\&.
.PP
\fBsd_event_source_disable_unref()\fR
and
\fBsd_event_source_disable_unrefp()\fR
were added in version 243\&.
.SH "SEE ALSO"
.PP
\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_enabled\fR(3)
.SH "NOTES"
.IP " 1." 4
Clean-up Variable Attribute
.RS 4
\%https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html
.RE