2 * Copyright (c) 2008-2013 Apple Inc. All rights reserved.
4 * @APPLE_APACHE_LICENSE_HEADER_START@
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * @APPLE_APACHE_LICENSE_HEADER_END@
22 * IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
23 * which are subject to change in future releases of Mac OS X. Any applications
24 * relying on these interfaces WILL break.
27 #ifndef __DISPATCH_SOURCE_PRIVATE__
28 #define __DISPATCH_SOURCE_PRIVATE__
30 #ifndef __DISPATCH_INDIRECT__
31 #error "Please #include <dispatch/private.h> instead of this file directly."
32 #include <dispatch/base.h> // for HeaderDoc
38 * @const DISPATCH_SOURCE_TYPE_TIMER_WITH_AGGREGATE
39 * @discussion A dispatch timer source that is part of a timer aggregate.
40 * The handle is the dispatch timer aggregate object.
41 * The mask specifies which flags from dispatch_source_timer_flags_t to apply.
43 #define DISPATCH_SOURCE_TYPE_TIMER_WITH_AGGREGATE \
44 (&_dispatch_source_type_timer_with_aggregate)
45 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
46 DISPATCH_SOURCE_TYPE_DECL(timer_with_aggregate
);
49 * @const DISPATCH_SOURCE_TYPE_INTERVAL
50 * @discussion A dispatch source that submits the event handler block at a
51 * specified time interval, phase-aligned with all other interval sources on
52 * the system that have the same interval value.
54 * The initial submission of the event handler will occur at some point during
55 * the first time interval after the source is created (assuming the source is
56 * resumed at that time).
58 * By default, the unit for the interval value is milliseconds and the leeway
59 * (maximum amount of time any individual handler submission may be deferred to
60 * align with other system activity) for the source is fixed at interval/2.
62 * If the DISPATCH_INTERVAL_UI_ANIMATION flag is specified, the unit for the
63 * interval value is animation frames (1/60th of a second) and the leeway is
66 * The handle is the interval value in milliseconds or frames.
67 * The mask specifies which flags from dispatch_source_timer_flags_t to apply.
69 #define DISPATCH_SOURCE_TYPE_INTERVAL (&_dispatch_source_type_interval)
70 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
71 DISPATCH_SOURCE_TYPE_DECL(interval
);
74 * @const DISPATCH_SOURCE_TYPE_VFS
75 * @discussion Apple-internal dispatch source that monitors for vfs events
76 * defined by dispatch_vfs_flags_t.
77 * The handle is a process identifier (pid_t).
79 #define DISPATCH_SOURCE_TYPE_VFS (&_dispatch_source_type_vfs)
80 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
81 DISPATCH_EXPORT
const struct dispatch_source_type_s _dispatch_source_type_vfs
;
84 * @const DISPATCH_SOURCE_TYPE_VM
85 * @discussion A dispatch source that monitors virtual memory
86 * The mask is a mask of desired events from dispatch_source_vm_flags_t.
87 * This type is deprecated, use DISPATCH_SOURCE_TYPE_MEMORYSTATUS instead.
89 #define DISPATCH_SOURCE_TYPE_VM (&_dispatch_source_type_vm)
90 __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_7
, __MAC_10_10
, __IPHONE_4_3
,
91 __IPHONE_8_0
, "Use DISPATCH_SOURCE_TYPE_MEMORYSTATUS instead")
92 DISPATCH_EXPORT
const struct dispatch_source_type_s _dispatch_source_type_vm
;
95 * @const DISPATCH_SOURCE_TYPE_MEMORYSTATUS
96 * @discussion A dispatch source that monitors memory status
97 * The mask is a mask of desired events from
98 * dispatch_source_memorystatus_flags_t.
100 #define DISPATCH_SOURCE_TYPE_MEMORYSTATUS (&_dispatch_source_type_memorystatus)
101 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_6_0
)
102 DISPATCH_EXPORT
const struct dispatch_source_type_s
103 _dispatch_source_type_memorystatus
;
106 * @const DISPATCH_SOURCE_TYPE_SOCK
107 * @discussion A dispatch source that monitors events on socket state changes.
109 #define DISPATCH_SOURCE_TYPE_SOCK (&_dispatch_source_type_sock)
110 __OSX_AVAILABLE_STARTING(__MAC_10_8
, __IPHONE_6_0
)
111 DISPATCH_EXPORT
const struct dispatch_source_type_s _dispatch_source_type_sock
;
116 * @enum dispatch_source_sock_flags_t
118 * @constant DISPATCH_SOCK_CONNRESET
121 * @constant DISPATCH_SOCK_READCLOSED
122 * Read side is shutdown
124 * @constant DISPATCH_SOCK_WRITECLOSED
125 * Write side is shutdown
127 * @constant DISPATCH_SOCK_TIMEOUT
128 * Timeout: rexmt, keep-alive or persist
130 * @constant DISPATCH_SOCK_NOSRCADDR
131 * Source address not available
133 * @constant DISPATCH_SOCK_IFDENIED
134 * Interface denied connection
136 * @constant DISPATCH_SOCK_SUSPEND
137 * Output queue suspended
139 * @constant DISPATCH_SOCK_RESUME
140 * Output queue resumed
142 * @constant DISPATCH_SOCK_KEEPALIVE
143 * TCP Keepalive received
145 * @constant DISPATCH_SOCK_CONNECTED
146 * Socket is connected
148 * @constant DISPATCH_SOCK_DISCONNECTED
149 * Socket is disconnected
151 * @constant DISPATCH_SOCK_CONNINFO_UPDATED
152 * Connection info was updated
155 DISPATCH_SOCK_CONNRESET
= 0x00000001,
156 DISPATCH_SOCK_READCLOSED
= 0x00000002,
157 DISPATCH_SOCK_WRITECLOSED
= 0x00000004,
158 DISPATCH_SOCK_TIMEOUT
= 0x00000008,
159 DISPATCH_SOCK_NOSRCADDR
= 0x00000010,
160 DISPATCH_SOCK_IFDENIED
= 0x00000020,
161 DISPATCH_SOCK_SUSPEND
= 0x00000040,
162 DISPATCH_SOCK_RESUME
= 0x00000080,
163 DISPATCH_SOCK_KEEPALIVE
= 0x00000100,
164 DISPATCH_SOCK_ADAPTIVE_WTIMO
= 0x00000200,
165 DISPATCH_SOCK_ADAPTIVE_RTIMO
= 0x00000400,
166 DISPATCH_SOCK_CONNECTED
= 0x00000800,
167 DISPATCH_SOCK_DISCONNECTED
= 0x00001000,
168 DISPATCH_SOCK_CONNINFO_UPDATED
= 0x00002000,
172 * @enum dispatch_source_vfs_flags_t
174 * @constant DISPATCH_VFS_NOTRESP
177 * @constant DISPATCH_VFS_NEEDAUTH
180 * @constant DISPATCH_VFS_LOWDISK
181 * We're low on space.
183 * @constant DISPATCH_VFS_MOUNT
184 * New filesystem arrived.
186 * @constant DISPATCH_VFS_UNMOUNT
187 * Filesystem has left.
189 * @constant DISPATCH_VFS_DEAD
190 * Filesystem is dead, needs force unmount.
192 * @constant DISPATCH_VFS_ASSIST
193 * Filesystem needs assistance from external program.
195 * @constant DISPATCH_VFS_NOTRESPLOCK
198 * @constant DISPATCH_VFS_UPDATE
199 * Filesystem information has changed.
201 * @constant DISPATCH_VFS_VERYLOWDISK
202 * File system has *very* little disk space left.
204 * @constant DISPATCH_VFS_QUOTA
205 * We hit a user quota (quotactl) for this filesystem.
208 DISPATCH_VFS_NOTRESP
= 0x0001,
209 DISPATCH_VFS_NEEDAUTH
= 0x0002,
210 DISPATCH_VFS_LOWDISK
= 0x0004,
211 DISPATCH_VFS_MOUNT
= 0x0008,
212 DISPATCH_VFS_UNMOUNT
= 0x0010,
213 DISPATCH_VFS_DEAD
= 0x0020,
214 DISPATCH_VFS_ASSIST
= 0x0040,
215 DISPATCH_VFS_NOTRESPLOCK
= 0x0080,
216 DISPATCH_VFS_UPDATE
= 0x0100,
217 DISPATCH_VFS_VERYLOWDISK
= 0x0200,
218 DISPATCH_VFS_QUOTA
= 0x1000,
222 * @enum dispatch_source_timer_flags_t
224 * @constant DISPATCH_TIMER_BACKGROUND
225 * Specifies that the timer is used to trigger low priority maintenance-level
226 * activity and that the system may apply larger minimum leeway values to the
227 * timer in order to align it with other system activity.
229 * @constant DISPATCH_INTERVAL_UI_ANIMATION
230 * Specifies that the interval source is used for UI animation. The unit for
231 * the interval value of such sources is frames (1/60th of a second) and the
232 * leeway is fixed at one frame.
235 DISPATCH_TIMER_BACKGROUND
= 0x2,
236 DISPATCH_INTERVAL_UI_ANIMATION
= 0x20,
240 * @enum dispatch_source_mach_send_flags_t
242 * @constant DISPATCH_MACH_SEND_POSSIBLE
243 * The mach port corresponding to the given send right has space available
244 * for messages. Delivered only once a mach_msg() to that send right with
245 * options MACH_SEND_MSG|MACH_SEND_TIMEOUT|MACH_SEND_NOTIFY has returned
246 * MACH_SEND_TIMED_OUT (and not again until the next such mach_msg() timeout).
247 * NOTE: The source must have registered the send right for monitoring with the
248 * system for such a mach_msg() to arm the send-possible notifcation, so
249 * the initial send attempt must occur from a source registration handler.
252 DISPATCH_MACH_SEND_POSSIBLE
= 0x8,
256 * @enum dispatch_source_proc_flags_t
258 * @constant DISPATCH_PROC_REAP
259 * The process has been reaped by the parent process via wait*().
260 * This flag is deprecated and will be removed in a future release.
263 DISPATCH_PROC_REAP
__OSX_AVAILABLE_BUT_DEPRECATED(
264 __MAC_10_6
, __MAC_10_9
, __IPHONE_4_0
, __IPHONE_7_0
) = 0x10000000,
268 * @enum dispatch_source_vm_flags_t
270 * @constant DISPATCH_VM_PRESSURE
271 * The VM has experienced memory pressure.
275 DISPATCH_VM_PRESSURE
__OSX_AVAILABLE_BUT_DEPRECATED_MSG(
276 __MAC_10_7
, __MAC_10_10
, __IPHONE_4_3
, __IPHONE_8_0
,
277 "Use DISPATCH_MEMORYSTATUS_PRESSURE_WARN instead") = 0x80000000,
281 * @enum dispatch_source_memorystatus_flags_t
283 * @constant DISPATCH_MEMORYSTATUS_PRESSURE_NORMAL
284 * The system's memory pressure state has returned to normal.
285 * @constant DISPATCH_MEMORYSTATUS_PRESSURE_WARN
286 * The system's memory pressure state has changed to warning.
287 * @constant DISPATCH_MEMORYSTATUS_PRESSURE_CRITICAL
288 * The system's memory pressure state has changed to critical.
289 * @constant DISPATCH_MEMORYSTATUS_LOW_SWAP
290 * The system's memory pressure state has entered the "low swap" condition.
291 * Restricted to the root user.
295 DISPATCH_MEMORYSTATUS_PRESSURE_NORMAL
296 __OSX_AVAILABLE_STARTING(__MAC_10_9
, __IPHONE_6_0
) = 0x01,
297 DISPATCH_MEMORYSTATUS_PRESSURE_WARN
298 __OSX_AVAILABLE_STARTING(__MAC_10_9
, __IPHONE_6_0
) = 0x02,
299 DISPATCH_MEMORYSTATUS_PRESSURE_CRITICAL
300 __OSX_AVAILABLE_STARTING(__MAC_10_9
, __IPHONE_8_0
) = 0x04,
301 DISPATCH_MEMORYSTATUS_LOW_SWAP
302 __OSX_AVAILABLE_STARTING(__MAC_10_10
, __IPHONE_8_0
) = 0x08,
308 * @typedef dispatch_timer_aggregate_t
311 * Dispatch timer aggregates are sets of related timers.
313 DISPATCH_DECL(dispatch_timer_aggregate
);
316 * @function dispatch_timer_aggregate_create
319 * Creates a new dispatch timer aggregate.
322 * A dispatch timer aggregate is a set of related timers whose overall timing
323 * parameters can be queried.
325 * Timers are added to an aggregate when a timer source is created with type
326 * DISPATCH_SOURCE_TYPE_TIMER_WITH_AGGREGATE.
329 * The newly created dispatch timer aggregate.
331 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
332 DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
334 dispatch_timer_aggregate_t
335 dispatch_timer_aggregate_create(void);
338 * @function dispatch_timer_aggregate_get_delay
341 * Retrieves the delay until a timer in the given aggregate will next fire.
344 * The dispatch timer aggregate to query.
347 * Optional pointer to a variable filled with the leeway (in ns) that will be
348 * applied to the return value. May be NULL.
351 * Delay in ns from now.
353 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
354 DISPATCH_EXPORT DISPATCH_NOTHROW
356 dispatch_timer_aggregate_get_delay(dispatch_timer_aggregate_t aggregate
,
357 uint64_t *leeway_ptr
);
361 * @typedef dispatch_mig_callback_t
364 * The signature of a function that handles Mach message delivery and response.
366 typedef boolean_t (*dispatch_mig_callback_t
)(mach_msg_header_t
*message
,
367 mach_msg_header_t
*reply
);
369 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
370 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
372 dispatch_mig_server(dispatch_source_t ds
, size_t maxmsgsz
,
373 dispatch_mig_callback_t callback
);
376 * @function dispatch_mach_msg_get_context
379 * Extract the context pointer from a mach message trailer.
381 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
382 DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NONNULL_ALL
385 dispatch_mach_msg_get_context(mach_msg_header_t
*msg
);