2 * Copyright (c) 2008-2009 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.
28 * LEGACY: This header file describles LEGACY interfaces to libdispatch from an
29 * earlier revision of the API. These interfaces WILL be removed in the future.
32 #ifndef __DISPATCH_LEGACY__
33 #define __DISPATCH_LEGACY__
35 #ifndef __DISPATCH_INDIRECT__
36 #error "Please #include <dispatch/dispatch.h> instead of this file directly."
37 #include <dispatch/base.h> // for HeaderDoc
40 #include <mach/mach_types.h>
42 #define DISPATCH_DEPRECATED __attribute__((deprecated))
43 #define DISPATCH_PUBLIC_API __attribute__((visibility("default")))
45 typedef struct dispatch_item_s
*dispatch_item_t
;
47 struct dispatch_item_s
{
48 void * di_objc_isa
; /* FIXME -- someday... */
49 struct dispatch_item_s
*volatile di_next
;
50 dispatch_queue_t di_cback_q
;
52 semaphore_t di_semaphore
;
60 // Use: dispatch_source_t
61 typedef struct dispatch_source_s
*dispatch_event_t
;
65 typedef void (^dispatch_legacy_block_t
)(dispatch_item_t
);
66 typedef void (^dispatch_queue_deletion_block_t
)(dispatch_queue_t queue
);
67 typedef void (^dispatch_source_deletion_t
)(dispatch_source_t source
);
68 typedef void (^dispatch_event_callback_t
)(dispatch_event_t event
);
69 typedef void (^dispatch_source_handler_t
)(dispatch_source_t source
);
70 typedef dispatch_source_handler_t dispatch_event_handler_t
;
71 typedef void (^dispatch_source_finalizer_t
)(dispatch_source_t source
);
72 #endif /* __BLOCKS__ */
75 typedef void (*dispatch_source_handler_function_t
)(void *, dispatch_source_t
);
76 typedef void (*dispatch_source_finalizer_function_t
)(void *, dispatch_source_t
);
77 typedef dispatch_source_handler_function_t dispatch_event_handler_function_t
;
79 DISPATCH_DECL(dispatch_source_attr
);
81 #define DISPATCH_SOURCE_CREATE_SUSPENDED ((dispatch_source_attr_t)~0ul)
84 typedef void (^dispatch_queue_finalizer_t
)(dispatch_queue_t queue
);
87 typedef void (*dispatch_queue_finalizer_function_t
)(void *, dispatch_queue_t
);
92 * @function dispatch_queue_attr_create
95 * Creates a new dispatch queue attribute structure. These attributes may be
96 * provided at creation time to modify the default behavior of the queue.
99 * The values present in this structure are copied to newly created queues.
100 * The same attribute structure may be provided to multiple calls to
101 * dispatch_queue_create() but only the values in the structure at the time the
102 * call is made will be used.
105 * The new dispatch queue attribute structure, initialized to default values.
107 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
108 DISPATCH_MALLOC DISPATCH_WARN_RESULT DISPATCH_NOTHROW
109 dispatch_queue_attr_t
110 dispatch_queue_attr_create(void);
113 * @function dispatch_queue_attr_set_priority
116 * Set the priority level for a dispatch queue.
119 * Priority levels may be:
120 * - DISPATCH_QUEUE_PRIORITY_HIGH
121 * - DISPATCH_QUEUE_PRIORITY_DEFAULT
122 * - DISPATCH_QUEUE_PRIORITY_LOW
123 * Queues set to high priority will be processed
124 * before queues set to default priority or low priority.
125 * Queues set to low priority will be processed only if all
126 * high priority and default priority queues are empty.
128 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
129 DISPATCH_NONNULL1 DISPATCH_NOTHROW
131 dispatch_queue_attr_set_priority(dispatch_queue_attr_t attr
, int priority
);
134 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
135 DISPATCH_NONNULL1 DISPATCH_NOTHROW
137 dispatch_queue_attr_set_finalizer(
138 dispatch_queue_attr_t attr
,
139 dispatch_queue_finalizer_t finalizer
);
142 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
143 DISPATCH_NONNULL1 DISPATCH_NOTHROW
145 dispatch_queue_attr_set_finalizer_f(dispatch_queue_attr_t attr
, void *context
, dispatch_queue_finalizer_function_t finalizer
);
148 * @function dispatch_get_concurrent_queue
151 * Returns a well-known global concurrent queue of a given priority level.
154 * Blocks submitted to the returned queue may be invoked concurrently with
155 * respect to each other.
157 * These queues are useful for performing one-shot asynchronous operations,
158 * e.g. dispatch_async() to an "anonymous" queue; or for performing parallel
159 * loops concurrently on multiple processors, e.g. dispatch_apply().
161 * The dispatch queues returned by this function are managed by the system for
162 * the lifetime of the application, and need not be retained or released
163 * directly by the application. Furthermore, dispatch_suspend() and
164 * dispatch_queue_resume() are not supported on these global queues, and will
168 * The requested priority level for the queue (default is zero):
169 * - DISPATCH_QUEUE_PRIORITY_HIGH
170 * - DISPATCH_QUEUE_PRIORITY_DEFAULT
171 * - DISPATCH_QUEUE_PRIORITY_LOW
174 * Returns a concurrent dispatch queue for use with dispatch_async(),
175 * dispatch_apply(), et al.
177 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
178 DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW
180 dispatch_get_concurrent_queue(long priority
);
182 DISPATCH_PUBLIC_API
//DISPATCH_DEPRECATED
184 dispatch_queue_attr_set_flags(dispatch_queue_attr_t attr
, uint64_t flags
);
187 DISPATCH_PUBLIC_API DISPATCH_NONNULL1 DISPATCH_NONNULL2 DISPATCH_DEPRECATED
189 dispatch_call(dispatch_queue_t
, dispatch_legacy_block_t work
, dispatch_legacy_block_t completion
)
190 __asm__("_dispatch_call2");
191 #endif /* __BLOCKS__ */
193 DISPATCH_PUBLIC_API DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_DEPRECATED
195 dispatch_queue_get_current(void);
197 // Use: dispatch_retain
198 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
200 dispatch_queue_retain(dispatch_queue_t
);
202 // Use: dispatch_release
203 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
205 dispatch_queue_release(dispatch_queue_t
);
207 // Use: dispatch_resume
208 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
210 dispatch_queue_resume(dispatch_queue_t
);
212 // Use: dispatch_release
213 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
215 dispatch_source_release(dispatch_source_t
);
217 // Use: dispatch_suspend
218 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
220 dispatch_source_suspend(dispatch_source_t
);
222 // Use: dispatch_resume
223 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
225 dispatch_source_resume(dispatch_source_t
);
227 // Use: dispatch_release
228 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
230 dispatch_queue_attr_release(dispatch_queue_attr_t
);
232 // Use: dispatch_release
233 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
235 dispatch_source_attr_release(dispatch_source_attr_t
);
237 // Use: dispatch_source_get_handle
238 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_DEPRECATED
240 dispatch_event_get_signals(dispatch_event_t event
);
242 // Use: dispatch_get_context
243 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL
//DISPATCH_DEPRECATED
245 dispatch_queue_get_context(dispatch_queue_t queue
);
247 // Use: dispatch_set_context
248 DISPATCH_PUBLIC_API DISPATCH_NONNULL1
//DISPATCH_DEPRECATED
250 dispatch_queue_set_context(dispatch_queue_t queue
, void *context
);
252 // Use: dispatch_get_context
253 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL
//DISPATCH_DEPRECATED
255 dispatch_source_get_context(dispatch_source_t source
);
257 // Use: dispatch_set_context
258 DISPATCH_PUBLIC_API DISPATCH_NONNULL1
//DISPATCH_DEPRECATED
260 dispatch_source_set_context(dispatch_source_t source
, void * context
);
262 // Use: dispatch_source_merge_data
263 DISPATCH_PUBLIC_API DISPATCH_NONNULL_ALL DISPATCH_DEPRECATED
265 dispatch_source_custom_trigger(dispatch_source_t ds
);
267 // Use: dispatch_source_cancel
268 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
269 DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
271 dispatch_cancel(dispatch_source_t
);
273 // Use: dispatch_source_testcancel
274 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
275 DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
277 dispatch_testcancel(dispatch_source_t
);
279 // Use: dispatch_source_set_timer
280 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
281 DISPATCH_NONNULL1 DISPATCH_NOTHROW
283 dispatch_source_timer_set_time(dispatch_source_t ds
,
284 uint64_t nanoseconds
,
287 // Use: dispatch_source_merge_data
288 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
289 DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
291 dispatch_source_trigger(dispatch_source_t source
, unsigned long value
);
294 DISPATCH_ERROR_DOMAIN_NO_ERROR
= 0,
295 DISPATCH_ERROR_DOMAIN_POSIX
= 1,
296 DISPATCH_ERROR_DOMAIN_MACH
= 2,
300 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
301 DISPATCH_NONNULL1 DISPATCH_WARN_RESULT DISPATCH_NOTHROW
303 dispatch_source_get_error(dispatch_source_t source
, long* error
);
305 // Use: dispatch_source_get_handle
306 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
307 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
309 dispatch_source_get_machport(dispatch_source_t source
);
311 // Use: dispatch_source_get_handle
312 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
313 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
315 dispatch_source_get_descriptor(dispatch_source_t source
);
317 // Use: dispatch_source_get_handle
318 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
319 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
321 dispatch_source_get_pid(dispatch_source_t source
);
323 // Use: dispatch_source_get_mask
324 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
325 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
327 dispatch_source_get_flags(dispatch_source_t source
);
329 // LEGACY: dispatch_event_t == dispatch_source_t
330 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
331 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
333 dispatch_event_get_source(dispatch_event_t event
);
335 // Use: dispatch_source_get_error
336 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
337 DISPATCH_NONNULL1 DISPATCH_WARN_RESULT DISPATCH_NOTHROW
339 dispatch_event_get_error(dispatch_event_t event
, long* error
);
341 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
342 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
344 dispatch_event_get_nanoseconds(dispatch_event_t event
);
346 // Use: dispatch_source_get_handle
347 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
348 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
350 dispatch_event_get_signal(dispatch_event_t event
);
352 // Use: dispatch_source_get_data
353 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
354 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
356 dispatch_event_get_flags(dispatch_event_t event
);
358 // Use: dispatch_source_get_data
359 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
360 DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
362 dispatch_event_get_bytes_available(dispatch_event_t event
);
364 // Use: dispatch_source_get_data
365 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
366 DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
368 dispatch_event_get_count(dispatch_event_t event
);
371 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
372 DISPATCH_MALLOC DISPATCH_WARN_RESULT DISPATCH_NOTHROW
373 dispatch_source_attr_t
374 dispatch_source_attr_create(void);
377 #if defined(__BLOCKS__)
378 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
380 dispatch_source_finalizer_t
381 dispatch_source_attr_get_finalizer(dispatch_source_attr_t attr
);
382 #endif /* __BLOCKS__ */
385 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
386 DISPATCH_MALLOC DISPATCH_WARN_RESULT DISPATCH_NOTHROW
387 dispatch_source_attr_t
388 dispatch_source_attr_copy(dispatch_source_attr_t proto
);
392 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
393 DISPATCH_NONNULL1 DISPATCH_NOTHROW
395 dispatch_source_attr_set_finalizer(
396 dispatch_source_attr_t attr
,
397 dispatch_source_finalizer_t finalizer
);
398 #endif /* __BLOCKS__ */
401 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
402 DISPATCH_NONNULL1 DISPATCH_NOTHROW
404 dispatch_source_attr_set_finalizer_f(
405 dispatch_source_attr_t attr
,
407 dispatch_source_finalizer_function_t finalizer
);
410 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
411 DISPATCH_NONNULL1 DISPATCH_NOTHROW
413 dispatch_source_attr_set_context(
414 dispatch_source_attr_t attr
,
417 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, ...)
418 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
419 DISPATCH_MALLOC DISPATCH_NONNULL4 DISPATCH_NONNULL5 DISPATCH_NOTHROW
421 dispatch_source_mig_create(
424 dispatch_source_attr_t attr
,
425 dispatch_queue_t queue
,
426 dispatch_mig_callback_t mig_callback
);
429 DISPATCH_TIMER_WALL_CLOCK
= 0x4,
433 DISPATCH_TIMER_INTERVAL
= 0x0,
434 DISPATCH_TIMER_ONESHOT
= 0x1,
435 DISPATCH_TIMER_ABSOLUTE
= 0x3,
438 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, ...)
440 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
441 DISPATCH_MALLOC DISPATCH_NONNULL5 DISPATCH_NONNULL6 DISPATCH_NOTHROW
443 dispatch_source_timer_create(
445 uint64_t nanoseconds
,
447 dispatch_source_attr_t attr
,
448 dispatch_queue_t queue
,
449 dispatch_source_handler_t handler
);
450 #endif /* __BLOCKS__ */
452 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, ...)
453 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
454 DISPATCH_MALLOC DISPATCH_NONNULL5 DISPATCH_NONNULL7 DISPATCH_NOTHROW
456 dispatch_source_timer_create_f(
458 uint64_t nanoseconds
,
460 dispatch_source_attr_t attr
,
461 dispatch_queue_t queue
,
463 dispatch_source_handler_function_t handler
);
465 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, ...)
467 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
468 DISPATCH_MALLOC DISPATCH_NOTHROW
470 dispatch_source_signal_create(
472 dispatch_source_attr_t attr
,
473 dispatch_queue_t queue
,
474 dispatch_source_handler_t handler
);
475 #endif /* __BLOCKS__ */
477 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, ...)
478 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
479 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL5 DISPATCH_NOTHROW
481 dispatch_source_signal_create_f(
483 dispatch_source_attr_t attr
,
484 dispatch_queue_t queue
,
486 dispatch_source_handler_function_t handler
);
488 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, ...)
490 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
491 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL4 DISPATCH_NOTHROW
493 dispatch_source_read_create(
495 dispatch_source_attr_t attr
,
496 dispatch_queue_t queue
,
497 dispatch_source_handler_t handler
);
498 #endif /* __BLOCKS__ */
500 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, ...)
501 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
502 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL5 DISPATCH_NOTHROW
504 dispatch_source_read_create_f(
506 dispatch_source_attr_t attr
,
507 dispatch_queue_t queue
,
509 dispatch_source_handler_function_t handler
);
511 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_WRITE, ...)
513 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
514 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL4 DISPATCH_NOTHROW
516 dispatch_source_write_create(
518 dispatch_source_attr_t attr
,
519 dispatch_queue_t queue
,
520 dispatch_source_handler_t handler
);
521 #endif /* __BLOCKS__ */
523 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_WRITE, ...)
524 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
525 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL5 DISPATCH_NOTHROW
527 dispatch_source_write_create_f(
529 dispatch_source_attr_t attr
,
530 dispatch_queue_t queue
,
532 dispatch_source_handler_function_t handler
);
534 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, ...)
536 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
537 DISPATCH_MALLOC DISPATCH_NONNULL4 DISPATCH_NONNULL5 DISPATCH_NOTHROW
539 dispatch_source_vnode_create(
542 dispatch_source_attr_t attr
,
543 dispatch_queue_t queue
,
544 dispatch_source_handler_t handler
);
545 #endif /* __BLOCKS__ */
547 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, ...)
548 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
549 DISPATCH_MALLOC DISPATCH_NONNULL4 DISPATCH_NONNULL6 DISPATCH_NOTHROW
551 dispatch_source_vnode_create_f(
554 dispatch_source_attr_t attr
,
555 dispatch_queue_t queue
,
557 dispatch_source_handler_function_t handler
);
559 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC, ...)
561 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
562 DISPATCH_MALLOC DISPATCH_NONNULL4 DISPATCH_NONNULL5 DISPATCH_NOTHROW
564 dispatch_source_proc_create(
567 dispatch_source_attr_t attr
,
568 dispatch_queue_t queue
,
569 dispatch_source_handler_t handler
);
570 #endif /* __BLOCKS__ */
572 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC, ...)
573 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
574 DISPATCH_MALLOC DISPATCH_NONNULL4 DISPATCH_NONNULL6 DISPATCH_NOTHROW
576 dispatch_source_proc_create_f(
579 dispatch_source_attr_t attr
,
580 dispatch_queue_t queue
,
582 dispatch_source_handler_function_t handler
);
585 DISPATCH_MACHPORT_DEAD
= 0x1,
586 DISPATCH_MACHPORT_RECV
= 0x2,
587 DISPATCH_MACHPORT_DELETED
= 0x4,
590 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, ...)
592 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
593 DISPATCH_MALLOC DISPATCH_NOTHROW
595 dispatch_source_machport_create(
598 dispatch_source_attr_t attr
,
599 dispatch_queue_t queue
,
600 dispatch_source_handler_t handler
);
601 #endif /* __BLOCKS__ */
603 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, ...)
604 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
605 DISPATCH_MALLOC DISPATCH_NOTHROW
607 dispatch_source_machport_create_f(
610 dispatch_source_attr_t attr
,
611 dispatch_queue_t queue
,
613 dispatch_source_handler_function_t handler
);
616 DISPATCH_SOURCE_DATA_ADD
= 1,
617 DISPATCH_SOURCE_DATA_OR
,
620 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_DATA..., ...)
622 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
623 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL4 DISPATCH_NOTHROW
625 dispatch_source_data_create(
626 unsigned long behavior
,
627 dispatch_source_attr_t attr
,
628 dispatch_queue_t queue
,
629 dispatch_source_handler_t handler
);
630 #endif /* __BLOCKS__ */
632 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_DATA..., ...)
633 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
634 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL5 DISPATCH_NOTHROW
636 dispatch_source_data_create_f(
637 unsigned long behavior
,
638 dispatch_source_attr_t attr
,
639 dispatch_queue_t queue
,
641 dispatch_source_handler_function_t handler
);
644 DISPATCH_SOURCE_CUSTOM_ADD
= DISPATCH_SOURCE_DATA_ADD
,
645 DISPATCH_SOURCE_CUSTOM_OR
= DISPATCH_SOURCE_DATA_OR
,
648 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_DATA..., ...)
650 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
651 DISPATCH_MALLOC DISPATCH_NONNULL2 DISPATCH_NONNULL3 DISPATCH_NOTHROW
653 dispatch_source_custom_create(
654 unsigned long behavior
,
655 dispatch_source_attr_t attr
,
656 dispatch_queue_t queue
,
657 dispatch_event_handler_t handler
);
658 #endif /* __BLOCKS__ */
660 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_DATA..., ...)
661 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
662 DISPATCH_MALLOC DISPATCH_NONNULL2 DISPATCH_NONNULL4 DISPATCH_NOTHROW
664 dispatch_source_custom_create_f(
665 unsigned long behavior
,
666 dispatch_source_attr_t attr
,
667 dispatch_queue_t queue
,
669 dispatch_event_handler_function_t handler
);
671 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_VFS, ...)
672 #if defined(__BLOCKS__)
673 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
674 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL4
676 dispatch_source_vfs_create(
678 dispatch_source_attr_t attr
,
679 dispatch_queue_t queue
,
680 dispatch_source_handler_t handler
);
681 #endif /* __BLOCKS__ */
683 // Use: dispatch_source_create(DISPATCH_SOURCE_TYPE_VFS, ...)
684 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
685 DISPATCH_MALLOC DISPATCH_NONNULL3 DISPATCH_NONNULL5
687 dispatch_source_vfs_create_f(
689 dispatch_source_attr_t attr
,
690 dispatch_queue_t queue
,
692 dispatch_source_handler_function_t handler
);
695 * Raw Mach message support from MIG source.
697 * It is possible to use the following callback style with the MIG source to
698 * obtain the raw mach message (and send no reply) similar to CFMachPort.
699 * (For more specific CFMachPort compatibility, see below).
701 * void handle_mach_msg(mach_msg_header *msg) { ... }
703 * DISPATCH_MACHPORT_CALLBACK_DECL(mig_compat_callback, handle_mach_msg);
705 * mig = dispatch_source_mig_create(mp, MY_MAX_MSG_SIZE, NULL,
706 * queue, mig_compat_callback);
708 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
710 _dispatch_machport_callback(mach_msg_header_t
*msg
, mach_msg_header_t
*reply
, void (*callback
)(mach_msg_header_t
*));
712 #define DISPATCH_MACHPORT_CALLBACK_DECL(new_callback, existing_callback) \
713 __private_extern__ boolean_t \
714 new_callback(mach_msg_header_t *msg, mach_msg_header_t *reply) \
715 { return _dispatch_machport_callback(msg, reply, existing_callback); }
718 * CFMachPort compatibility.
720 * It is possible to use existing CFMachPort callbacks with dispatch mig sources
721 * by delcaring the following shim and using the shim as the mig server callback
722 * to dispatch_source_mig_create().
723 * The CFMachPortRef "port" parameter of the CFMachPortCallBack will be NULL.
724 * If mach_port_set_context() is used, that value will be passed into the "info"
725 * parameter of the CFMachPortCallBack.
727 * DISPATCH_CFMACHPORT_CALLBACK_DECL(mig_callback, MyCFMachPortCallBack);
731 * kr = mach_port_set_context(mach_task_self(), mp, (mach_vm_address_t)context);
732 * mig = dispatch_source_mig_create(mp, MY_MAX_MSG_SIZE, NULL,
733 * queue, mig_callback);
737 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
739 _dispatch_CFMachPortCallBack(mach_msg_header_t
*msg
, mach_msg_header_t
*reply
, void (*callback
)(struct __CFMachPort
*, void *msg
, signed long size
, void *));
741 #define DISPATCH_CFMACHPORT_CALLBACK_DECL(new_callback, existing_callback) \
742 __private_extern__ boolean_t \
743 new_callback(mach_msg_header_t *msg, mach_msg_header_t *reply) \
744 { return _dispatch_CFMachPortCallBack(msg, reply, existing_callback); }