]>
Commit | Line | Data |
---|---|---|
0ab74447 | 1 | /* |
517da941 | 2 | * Copyright (c) 2008-2013 Apple Inc. All rights reserved. |
0ab74447 A |
3 | * |
4 | * @APPLE_APACHE_LICENSE_HEADER_START@ | |
e85f4437 | 5 | * |
0ab74447 A |
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 | |
e85f4437 | 9 | * |
0ab74447 | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
e85f4437 | 11 | * |
0ab74447 A |
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. | |
e85f4437 | 17 | * |
0ab74447 A |
18 | * @APPLE_APACHE_LICENSE_HEADER_END@ |
19 | */ | |
20 | ||
21 | /* | |
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. | |
25 | */ | |
26 | ||
27 | #ifndef __DISPATCH_SOURCE_PRIVATE__ | |
28 | #define __DISPATCH_SOURCE_PRIVATE__ | |
29 | ||
30 | #ifndef __DISPATCH_INDIRECT__ | |
c093abd6 | 31 | #error "Please #include <dispatch/private.h> instead of this file directly." |
0ab74447 A |
32 | #include <dispatch/base.h> // for HeaderDoc |
33 | #endif | |
34 | ||
45201a42 A |
35 | __BEGIN_DECLS |
36 | ||
517da941 A |
37 | /*! |
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. | |
42 | */ | |
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); | |
47 | ||
48 | /*! | |
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. | |
53 | * | |
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). | |
57 | * | |
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. | |
61 | * | |
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 | |
64 | * fixed at one frame. | |
65 | * | |
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. | |
68 | */ | |
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); | |
72 | ||
0ab74447 A |
73 | /*! |
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). | |
78 | */ | |
79 | #define DISPATCH_SOURCE_TYPE_VFS (&_dispatch_source_type_vfs) | |
e85f4437 A |
80 | __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0) |
81 | DISPATCH_EXPORT const struct dispatch_source_type_s _dispatch_source_type_vfs; | |
82 | ||
83 | /*! | |
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. | |
98cf8cd2 | 87 | * This type is deprecated, use DISPATCH_SOURCE_TYPE_MEMORYSTATUS instead. |
e85f4437 A |
88 | */ |
89 | #define DISPATCH_SOURCE_TYPE_VM (&_dispatch_source_type_vm) | |
98cf8cd2 A |
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") | |
e85f4437 | 92 | DISPATCH_EXPORT const struct dispatch_source_type_s _dispatch_source_type_vm; |
0ab74447 | 93 | |
517da941 A |
94 | /*! |
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. | |
99 | */ | |
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; | |
104 | ||
c093abd6 A |
105 | /*! |
106 | * @const DISPATCH_SOURCE_TYPE_SOCK | |
107 | * @discussion A dispatch source that monitors events on socket state changes. | |
108 | */ | |
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; | |
112 | ||
45201a42 A |
113 | __END_DECLS |
114 | ||
c093abd6 A |
115 | /*! |
116 | * @enum dispatch_source_sock_flags_t | |
117 | * | |
118 | * @constant DISPATCH_SOCK_CONNRESET | |
119 | * Received RST | |
120 | * | |
121 | * @constant DISPATCH_SOCK_READCLOSED | |
122 | * Read side is shutdown | |
123 | * | |
124 | * @constant DISPATCH_SOCK_WRITECLOSED | |
125 | * Write side is shutdown | |
126 | * | |
127 | * @constant DISPATCH_SOCK_TIMEOUT | |
128 | * Timeout: rexmt, keep-alive or persist | |
129 | * | |
130 | * @constant DISPATCH_SOCK_NOSRCADDR | |
131 | * Source address not available | |
132 | * | |
133 | * @constant DISPATCH_SOCK_IFDENIED | |
134 | * Interface denied connection | |
135 | * | |
136 | * @constant DISPATCH_SOCK_SUSPEND | |
137 | * Output queue suspended | |
138 | * | |
139 | * @constant DISPATCH_SOCK_RESUME | |
140 | * Output queue resumed | |
141 | * | |
142 | * @constant DISPATCH_SOCK_KEEPALIVE | |
143 | * TCP Keepalive received | |
144 | * | |
517da941 A |
145 | * @constant DISPATCH_SOCK_CONNECTED |
146 | * Socket is connected | |
147 | * | |
148 | * @constant DISPATCH_SOCK_DISCONNECTED | |
149 | * Socket is disconnected | |
150 | * | |
151 | * @constant DISPATCH_SOCK_CONNINFO_UPDATED | |
152 | * Connection info was updated | |
c093abd6 A |
153 | */ |
154 | enum { | |
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, | |
517da941 A |
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, | |
c093abd6 A |
169 | }; |
170 | ||
0ab74447 A |
171 | /*! |
172 | * @enum dispatch_source_vfs_flags_t | |
173 | * | |
174 | * @constant DISPATCH_VFS_NOTRESP | |
175 | * Server down. | |
176 | * | |
177 | * @constant DISPATCH_VFS_NEEDAUTH | |
178 | * Server bad auth. | |
179 | * | |
180 | * @constant DISPATCH_VFS_LOWDISK | |
181 | * We're low on space. | |
182 | * | |
183 | * @constant DISPATCH_VFS_MOUNT | |
184 | * New filesystem arrived. | |
185 | * | |
186 | * @constant DISPATCH_VFS_UNMOUNT | |
187 | * Filesystem has left. | |
188 | * | |
189 | * @constant DISPATCH_VFS_DEAD | |
190 | * Filesystem is dead, needs force unmount. | |
191 | * | |
192 | * @constant DISPATCH_VFS_ASSIST | |
193 | * Filesystem needs assistance from external program. | |
194 | * | |
195 | * @constant DISPATCH_VFS_NOTRESPLOCK | |
196 | * Server lockd down. | |
197 | * | |
198 | * @constant DISPATCH_VFS_UPDATE | |
199 | * Filesystem information has changed. | |
200 | * | |
201 | * @constant DISPATCH_VFS_VERYLOWDISK | |
202 | * File system has *very* little disk space left. | |
203 | */ | |
204 | enum { | |
205 | DISPATCH_VFS_NOTRESP = 0x0001, | |
206 | DISPATCH_VFS_NEEDAUTH = 0x0002, | |
207 | DISPATCH_VFS_LOWDISK = 0x0004, | |
208 | DISPATCH_VFS_MOUNT = 0x0008, | |
209 | DISPATCH_VFS_UNMOUNT = 0x0010, | |
210 | DISPATCH_VFS_DEAD = 0x0020, | |
211 | DISPATCH_VFS_ASSIST = 0x0040, | |
212 | DISPATCH_VFS_NOTRESPLOCK = 0x0080, | |
213 | DISPATCH_VFS_UPDATE = 0x0100, | |
214 | DISPATCH_VFS_VERYLOWDISK = 0x0200, | |
215 | }; | |
216 | ||
517da941 A |
217 | /*! |
218 | * @enum dispatch_source_timer_flags_t | |
219 | * | |
220 | * @constant DISPATCH_TIMER_BACKGROUND | |
221 | * Specifies that the timer is used to trigger low priority maintenance-level | |
222 | * activity and that the system may apply larger minimum leeway values to the | |
223 | * timer in order to align it with other system activity. | |
224 | * | |
225 | * @constant DISPATCH_INTERVAL_UI_ANIMATION | |
226 | * Specifies that the interval source is used for UI animation. The unit for | |
227 | * the interval value of such sources is frames (1/60th of a second) and the | |
228 | * leeway is fixed at one frame. | |
229 | */ | |
230 | enum { | |
231 | DISPATCH_TIMER_BACKGROUND = 0x2, | |
232 | DISPATCH_INTERVAL_UI_ANIMATION = 0x20, | |
233 | }; | |
234 | ||
0ab74447 A |
235 | /*! |
236 | * @enum dispatch_source_mach_send_flags_t | |
237 | * | |
e85f4437 A |
238 | * @constant DISPATCH_MACH_SEND_POSSIBLE |
239 | * The mach port corresponding to the given send right has space available | |
240 | * for messages. Delivered only once a mach_msg() to that send right with | |
241 | * options MACH_SEND_MSG|MACH_SEND_TIMEOUT|MACH_SEND_NOTIFY has returned | |
242 | * MACH_SEND_TIMED_OUT (and not again until the next such mach_msg() timeout). | |
243 | * NOTE: The source must have registered the send right for monitoring with the | |
244 | * system for such a mach_msg() to arm the send-possible notifcation, so | |
245 | * the initial send attempt must occur from a source registration handler. | |
0ab74447 A |
246 | */ |
247 | enum { | |
e85f4437 | 248 | DISPATCH_MACH_SEND_POSSIBLE = 0x8, |
0ab74447 A |
249 | }; |
250 | ||
251 | /*! | |
252 | * @enum dispatch_source_proc_flags_t | |
253 | * | |
254 | * @constant DISPATCH_PROC_REAP | |
517da941 A |
255 | * The process has been reaped by the parent process via wait*(). |
256 | * This flag is deprecated and will be removed in a future release. | |
0ab74447 A |
257 | */ |
258 | enum { | |
517da941 A |
259 | DISPATCH_PROC_REAP __OSX_AVAILABLE_BUT_DEPRECATED( |
260 | __MAC_10_6, __MAC_10_9, __IPHONE_4_0, __IPHONE_7_0) = 0x10000000, | |
0ab74447 A |
261 | }; |
262 | ||
e85f4437 A |
263 | /*! |
264 | * @enum dispatch_source_vm_flags_t | |
265 | * | |
266 | * @constant DISPATCH_VM_PRESSURE | |
267 | * The VM has experienced memory pressure. | |
268 | */ | |
269 | ||
270 | enum { | |
98cf8cd2 A |
271 | DISPATCH_VM_PRESSURE __OSX_AVAILABLE_BUT_DEPRECATED_MSG( |
272 | __MAC_10_7, __MAC_10_10, __IPHONE_4_3, __IPHONE_8_0, | |
273 | "Use DISPATCH_MEMORYSTATUS_PRESSURE_WARN instead") = 0x80000000, | |
e85f4437 A |
274 | }; |
275 | ||
517da941 A |
276 | /*! |
277 | * @enum dispatch_source_memorystatus_flags_t | |
278 | * | |
279 | * @constant DISPATCH_MEMORYSTATUS_PRESSURE_NORMAL | |
280 | * The system's memory pressure state has returned to normal. | |
281 | * @constant DISPATCH_MEMORYSTATUS_PRESSURE_WARN | |
282 | * The system's memory pressure state has changed to warning. | |
283 | * @constant DISPATCH_MEMORYSTATUS_PRESSURE_CRITICAL | |
284 | * The system's memory pressure state has changed to critical. | |
98cf8cd2 A |
285 | * @constant DISPATCH_MEMORYSTATUS_LOW_SWAP |
286 | * The system's memory pressure state has entered the "low swap" condition. | |
287 | * Restricted to the root user. | |
517da941 A |
288 | */ |
289 | ||
290 | enum { | |
98cf8cd2 A |
291 | DISPATCH_MEMORYSTATUS_PRESSURE_NORMAL |
292 | __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_6_0) = 0x01, | |
293 | DISPATCH_MEMORYSTATUS_PRESSURE_WARN | |
294 | __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_6_0) = 0x02, | |
295 | DISPATCH_MEMORYSTATUS_PRESSURE_CRITICAL | |
296 | __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_8_0) = 0x04, | |
297 | DISPATCH_MEMORYSTATUS_LOW_SWAP | |
298 | __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0) = 0x08, | |
517da941 A |
299 | }; |
300 | ||
0ab74447 A |
301 | __BEGIN_DECLS |
302 | ||
517da941 A |
303 | /*! |
304 | * @typedef dispatch_timer_aggregate_t | |
305 | * | |
306 | * @abstract | |
307 | * Dispatch timer aggregates are sets of related timers. | |
308 | */ | |
309 | DISPATCH_DECL(dispatch_timer_aggregate); | |
310 | ||
311 | /*! | |
312 | * @function dispatch_timer_aggregate_create | |
313 | * | |
314 | * @abstract | |
315 | * Creates a new dispatch timer aggregate. | |
316 | * | |
317 | * @discussion | |
318 | * A dispatch timer aggregate is a set of related timers whose overall timing | |
319 | * parameters can be queried. | |
320 | * | |
321 | * Timers are added to an aggregate when a timer source is created with type | |
322 | * DISPATCH_SOURCE_TYPE_TIMER_WITH_AGGREGATE. | |
323 | * | |
324 | * @result | |
325 | * The newly created dispatch timer aggregate. | |
326 | */ | |
327 | __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0) | |
328 | DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT | |
329 | DISPATCH_NOTHROW | |
330 | dispatch_timer_aggregate_t | |
331 | dispatch_timer_aggregate_create(void); | |
332 | ||
333 | /*! | |
334 | * @function dispatch_timer_aggregate_get_delay | |
335 | * | |
336 | * @abstract | |
337 | * Retrieves the delay until a timer in the given aggregate will next fire. | |
338 | * | |
339 | * @param aggregate | |
340 | * The dispatch timer aggregate to query. | |
341 | * | |
342 | * @param leeway_ptr | |
343 | * Optional pointer to a variable filled with the leeway (in ns) that will be | |
344 | * applied to the return value. May be NULL. | |
345 | * | |
346 | * @result | |
347 | * Delay in ns from now. | |
348 | */ | |
349 | __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0) | |
350 | DISPATCH_EXPORT DISPATCH_NOTHROW | |
351 | uint64_t | |
352 | dispatch_timer_aggregate_get_delay(dispatch_timer_aggregate_t aggregate, | |
353 | uint64_t *leeway_ptr); | |
354 | ||
e85f4437 | 355 | #if TARGET_OS_MAC |
0ab74447 A |
356 | /*! |
357 | * @typedef dispatch_mig_callback_t | |
358 | * | |
359 | * @abstract | |
360 | * The signature of a function that handles Mach message delivery and response. | |
361 | */ | |
e85f4437 A |
362 | typedef boolean_t (*dispatch_mig_callback_t)(mach_msg_header_t *message, |
363 | mach_msg_header_t *reply); | |
0ab74447 | 364 | |
e85f4437 A |
365 | __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0) |
366 | DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW | |
0ab74447 | 367 | mach_msg_return_t |
e85f4437 A |
368 | dispatch_mig_server(dispatch_source_t ds, size_t maxmsgsz, |
369 | dispatch_mig_callback_t callback); | |
517da941 A |
370 | |
371 | /*! | |
372 | * @function dispatch_mach_msg_get_context | |
373 | * | |
374 | * @abstract | |
375 | * Extract the context pointer from a mach message trailer. | |
376 | */ | |
377 | __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0) | |
378 | DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NONNULL_ALL | |
379 | DISPATCH_NOTHROW | |
380 | void * | |
381 | dispatch_mach_msg_get_context(mach_msg_header_t *msg); | |
e85f4437 | 382 | #endif |
0ab74447 A |
383 | |
384 | __END_DECLS | |
385 | ||
386 | #endif |