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@ 
  21 #ifndef __DISPATCH_SOURCE__ 
  22 #define __DISPATCH_SOURCE__ 
  24 #ifndef __DISPATCH_INDIRECT__ 
  25 #error "Please #include <dispatch/dispatch.h> instead of this file directly." 
  26 #include <dispatch/base.h> // for HeaderDoc 
  30 #include <mach/port.h> 
  31 #include <mach/message.h> 
  35 #include <sys/signal.h> 
  40  * The dispatch framework provides a suite of interfaces for monitoring low- 
  41  * level system objects (file descriptors, Mach ports, signals, VFS nodes, etc.) 
  42  * for activity and automatically submitting event handler blocks to dispatch 
  43  * queues when such activity occurs. 
  45  * This suite of interfaces is known as the Dispatch Source API. 
  49  * @typedef dispatch_source_t 
  52  * Dispatch sources are used to automatically submit event handler blocks to 
  53  * dispatch queues in response to external events. 
  55 DISPATCH_DECL(dispatch_source
); 
  58  * @typedef dispatch_source_type_t 
  61  * Constants of this type represent the class of low-level system object that 
  62  * is being monitored by the dispatch source. Constants of this type are 
  63  * passed as a parameter to dispatch_source_create() and determine how the 
  64  * handle argument is interpreted (i.e. as a file descriptor, mach port, 
  65  * signal number, process identifer, etc.), and how the mask arugment is 
  68 typedef const struct dispatch_source_type_s 
*dispatch_source_type_t
; 
  72 #define DISPATCH_SOURCE_TYPE_DECL(name) \ 
  73         DISPATCH_EXPORT const struct dispatch_source_type_s \ 
  74         _dispatch_source_type_##name 
  76 #define DISPATCH_SOURCE_TYPE_DECL(name) \ 
  77         DISPATCH_EXPORT struct dispatch_source_type_s _dispatch_source_type_##name 
  81  * @const DISPATCH_SOURCE_TYPE_DATA_ADD 
  82  * @discussion A dispatch source that coalesces data obtained via calls to 
  83  * dispatch_source_merge_data(). An ADD is used to coalesce the data. 
  84  * The handle is unused (pass zero for now). 
  85  * The mask is unused (pass zero for now). 
  87 #define DISPATCH_SOURCE_TYPE_DATA_ADD (&_dispatch_source_type_data_add) 
  88 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
  89 DISPATCH_SOURCE_TYPE_DECL(data_add
); 
  92  * @const DISPATCH_SOURCE_TYPE_DATA_OR 
  93  * @discussion A dispatch source that coalesces data obtained via calls to 
  94  * dispatch_source_merge_data(). A bitwise OR is used to coalesce the data. 
  95  * The handle is unused (pass zero for now). 
  96  * The mask is unused (pass zero for now). 
  98 #define DISPATCH_SOURCE_TYPE_DATA_OR (&_dispatch_source_type_data_or) 
  99 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 100 DISPATCH_SOURCE_TYPE_DECL(data_or
); 
 103  * @const DISPATCH_SOURCE_TYPE_MACH_SEND 
 104  * @discussion A dispatch source that monitors a Mach port for dead name 
 105  * notifications (send right no longer has any corresponding receive right). 
 106  * The handle is a Mach port with a send or send-once right (mach_port_t). 
 107  * The mask is a mask of desired events from dispatch_source_mach_send_flags_t. 
 109 #define DISPATCH_SOURCE_TYPE_MACH_SEND (&_dispatch_source_type_mach_send) 
 110 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 111 DISPATCH_SOURCE_TYPE_DECL(mach_send
); 
 114  * @const DISPATCH_SOURCE_TYPE_MACH_RECV 
 115  * @discussion A dispatch source that monitors a Mach port for pending messages. 
 116  * The handle is a Mach port with a receive right (mach_port_t). 
 117  * The mask is unused (pass zero for now). 
 119 #define DISPATCH_SOURCE_TYPE_MACH_RECV (&_dispatch_source_type_mach_recv) 
 120 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 121 DISPATCH_SOURCE_TYPE_DECL(mach_recv
); 
 124  * @const DISPATCH_SOURCE_TYPE_MEMORYPRESSURE 
 125  * @discussion A dispatch source that monitors the system for changes in 
 126  * memory pressure condition. 
 127  * The handle is unused (pass zero for now). 
 128  * The mask is a mask of desired events from 
 129  * dispatch_source_memorypressure_flags_t. 
 131 #define DISPATCH_SOURCE_TYPE_MEMORYPRESSURE \ 
 132                 (&_dispatch_source_type_memorypressure) 
 133 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_NA
) 
 134 DISPATCH_SOURCE_TYPE_DECL(memorypressure
); 
 137  * @const DISPATCH_SOURCE_TYPE_PROC 
 138  * @discussion A dispatch source that monitors an external process for events 
 139  * defined by dispatch_source_proc_flags_t. 
 140  * The handle is a process identifier (pid_t). 
 141  * The mask is a mask of desired events from dispatch_source_proc_flags_t. 
 143 #define DISPATCH_SOURCE_TYPE_PROC (&_dispatch_source_type_proc) 
 144 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 145 DISPATCH_SOURCE_TYPE_DECL(proc
); 
 148  * @const DISPATCH_SOURCE_TYPE_READ 
 149  * @discussion A dispatch source that monitors a file descriptor for pending 
 150  * bytes available to be read. 
 151  * The handle is a file descriptor (int). 
 152  * The mask is unused (pass zero for now). 
 154 #define DISPATCH_SOURCE_TYPE_READ (&_dispatch_source_type_read) 
 155 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 156 DISPATCH_SOURCE_TYPE_DECL(read
); 
 159  * @const DISPATCH_SOURCE_TYPE_SIGNAL 
 160  * @discussion A dispatch source that monitors the current process for signals. 
 161  * The handle is a signal number (int). 
 162  * The mask is unused (pass zero for now). 
 164 #define DISPATCH_SOURCE_TYPE_SIGNAL (&_dispatch_source_type_signal) 
 165 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 166 DISPATCH_SOURCE_TYPE_DECL(signal
); 
 169  * @const DISPATCH_SOURCE_TYPE_TIMER 
 170  * @discussion A dispatch source that submits the event handler block based 
 172  * The handle is unused (pass zero for now). 
 173  * The mask specifies which flags from dispatch_source_timer_flags_t to apply. 
 175 #define DISPATCH_SOURCE_TYPE_TIMER (&_dispatch_source_type_timer) 
 176 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 177 DISPATCH_SOURCE_TYPE_DECL(timer
); 
 180  * @const DISPATCH_SOURCE_TYPE_VNODE 
 181  * @discussion A dispatch source that monitors a file descriptor for events 
 182  * defined by dispatch_source_vnode_flags_t. 
 183  * The handle is a file descriptor (int). 
 184  * The mask is a mask of desired events from dispatch_source_vnode_flags_t. 
 186 #define DISPATCH_SOURCE_TYPE_VNODE (&_dispatch_source_type_vnode) 
 187 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 188 DISPATCH_SOURCE_TYPE_DECL(vnode
); 
 191  * @const DISPATCH_SOURCE_TYPE_WRITE 
 192  * @discussion A dispatch source that monitors a file descriptor for available 
 193  * buffer space to write bytes. 
 194  * The handle is a file descriptor (int). 
 195  * The mask is unused (pass zero for now). 
 197 #define DISPATCH_SOURCE_TYPE_WRITE (&_dispatch_source_type_write) 
 198 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 199 DISPATCH_SOURCE_TYPE_DECL(write
); 
 202  * @typedef dispatch_source_mach_send_flags_t 
 203  * Type of dispatch_source_mach_send flags 
 205  * @constant DISPATCH_MACH_SEND_DEAD 
 206  * The receive right corresponding to the given send right was destroyed. 
 208 #define DISPATCH_MACH_SEND_DEAD 0x1 
 210 typedef unsigned long dispatch_source_mach_send_flags_t
; 
 213  * @typedef dispatch_source_memorypressure_flags_t 
 214  * Type of dispatch_source_memorypressure flags 
 216  * @constant DISPATCH_MEMORYPRESSURE_NORMAL 
 217  * The system memory pressure condition has returned to normal. 
 219  * @constant DISPATCH_MEMORYPRESSURE_WARN 
 220  * The system memory pressure condition has changed to warning. 
 222  * @constant DISPATCH_MEMORYPRESSURE_CRITICAL 
 223  * The system memory pressure condition has changed to critical. 
 226  * Elevated memory pressure is a system-wide condition that applications 
 227  * registered for this source should react to by changing their future memory 
 228  * use behavior, e.g. by reducing cache sizes of newly initiated operations 
 229  * until memory pressure returns back to normal. 
 230  * NOTE: applications should NOT traverse and discard existing caches for past 
 231  * operations when the system memory pressure enters an elevated state, as that 
 232  * is likely to trigger VM operations that will further aggravate system memory 
 236 #define DISPATCH_MEMORYPRESSURE_NORMAL          0x01 
 237 #define DISPATCH_MEMORYPRESSURE_WARN            0x02 
 238 #define DISPATCH_MEMORYPRESSURE_CRITICAL        0x04 
 240 typedef unsigned long dispatch_source_memorypressure_flags_t
; 
 243  * @typedef dispatch_source_proc_flags_t 
 244  * Type of dispatch_source_proc flags 
 246  * @constant DISPATCH_PROC_EXIT 
 247  * The process has exited (perhaps cleanly, perhaps not). 
 249  * @constant DISPATCH_PROC_FORK 
 250  * The process has created one or more child processes. 
 252  * @constant DISPATCH_PROC_EXEC 
 253  * The process has become another executable image via 
 254  * exec*() or posix_spawn*(). 
 256  * @constant DISPATCH_PROC_SIGNAL 
 257  * A Unix signal was delivered to the process. 
 259 #define DISPATCH_PROC_EXIT              0x80000000 
 260 #define DISPATCH_PROC_FORK              0x40000000 
 261 #define DISPATCH_PROC_EXEC              0x20000000 
 262 #define DISPATCH_PROC_SIGNAL    0x08000000 
 264 typedef unsigned long dispatch_source_proc_flags_t
; 
 267  * @typedef dispatch_source_vnode_flags_t 
 268  * Type of dispatch_source_vnode flags 
 270  * @constant DISPATCH_VNODE_DELETE 
 271  * The filesystem object was deleted from the namespace. 
 273  * @constant DISPATCH_VNODE_WRITE 
 274  * The filesystem object data changed. 
 276  * @constant DISPATCH_VNODE_EXTEND 
 277  * The filesystem object changed in size. 
 279  * @constant DISPATCH_VNODE_ATTRIB 
 280  * The filesystem object metadata changed. 
 282  * @constant DISPATCH_VNODE_LINK 
 283  * The filesystem object link count changed. 
 285  * @constant DISPATCH_VNODE_RENAME 
 286  * The filesystem object was renamed in the namespace. 
 288  * @constant DISPATCH_VNODE_REVOKE 
 289  * The filesystem object was revoked. 
 292 #define DISPATCH_VNODE_DELETE   0x1 
 293 #define DISPATCH_VNODE_WRITE    0x2 
 294 #define DISPATCH_VNODE_EXTEND   0x4 
 295 #define DISPATCH_VNODE_ATTRIB   0x8 
 296 #define DISPATCH_VNODE_LINK             0x10 
 297 #define DISPATCH_VNODE_RENAME   0x20 
 298 #define DISPATCH_VNODE_REVOKE   0x40 
 300 typedef unsigned long dispatch_source_vnode_flags_t
; 
 303  * @typedef dispatch_source_timer_flags_t 
 304  * Type of dispatch_source_timer flags 
 306  * @constant DISPATCH_TIMER_STRICT 
 307  * Specifies that the system should make a best effort to strictly observe the 
 308  * leeway value specified for the timer via dispatch_source_set_timer(), even 
 309  * if that value is smaller than the default leeway value that would be applied 
 310  * to the timer otherwise. A minimal amount of leeway will be applied to the 
 311  * timer even if this flag is specified. 
 313  * CAUTION: Use of this flag may override power-saving techniques employed by 
 314  * the system and cause higher power consumption, so it must be used with care 
 315  * and only when absolutely necessary. 
 318 #define DISPATCH_TIMER_STRICT 0x1 
 320 typedef unsigned long dispatch_source_timer_flags_t
; 
 325  * @function dispatch_source_create 
 328  * Creates a new dispatch source to monitor low-level system objects and auto- 
 329  * matically submit a handler block to a dispatch queue in response to events. 
 332  * Dispatch sources are not reentrant. Any events received while the dispatch 
 333  * source is suspended or while the event handler block is currently executing 
 334  * will be coalesced and delivered after the dispatch source is resumed or the 
 335  * event handler block has returned. 
 337  * Dispatch sources are created in a suspended state. After creating the 
 338  * source and setting any desired attributes (i.e. the handler, context, etc.), 
 339  * a call must be made to dispatch_resume() in order to begin event delivery. 
 342  * Declares the type of the dispatch source. Must be one of the defined 
 343  * dispatch_source_type_t constants. 
 345  * The underlying system handle to monitor. The interpretation of this argument 
 346  * is determined by the constant provided in the type parameter. 
 348  * A mask of flags specifying which events are desired. The interpretation of 
 349  * this argument is determined by the constant provided in the type parameter. 
 351  * The dispatch queue to which the event handler block will be submitted. 
 352  * If queue is DISPATCH_TARGET_QUEUE_DEFAULT, the source will submit the event 
 353  * handler block to the default priority global queue. 
 355 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 356 DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
 
 359 dispatch_source_create(dispatch_source_type_t type
, 
 362         dispatch_queue_t queue
); 
 365  * @function dispatch_source_set_event_handler 
 368  * Sets the event handler block for the given dispatch source. 
 371  * The dispatch source to modify. 
 372  * The result of passing NULL in this parameter is undefined. 
 375  * The event handler block to submit to the source's target queue. 
 378 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 379 DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
 
 381 dispatch_source_set_event_handler(dispatch_source_t source
, 
 382         dispatch_block_t handler
); 
 383 #endif /* __BLOCKS__ */ 
 386  * @function dispatch_source_set_event_handler_f 
 389  * Sets the event handler function for the given dispatch source. 
 392  * The dispatch source to modify. 
 393  * The result of passing NULL in this parameter is undefined. 
 396  * The event handler function to submit to the source's target queue. 
 397  * The context parameter passed to the event handler function is the current 
 398  * context of the dispatch source at the time the handler call is made. 
 399  * The result of passing NULL in this parameter is undefined. 
 401 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 402 DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
 
 404 dispatch_source_set_event_handler_f(dispatch_source_t source
, 
 405         dispatch_function_t handler
); 
 408  * @function dispatch_source_set_cancel_handler 
 411  * Sets the cancellation handler block for the given dispatch source. 
 414  * The cancellation handler (if specified) will be submitted to the source's 
 415  * target queue in response to a call to dispatch_source_cancel() once the 
 416  * system has released all references to the source's underlying handle and 
 417  * the source's event handler block has returned. 
 420  * A cancellation handler is required for file descriptor and mach port based 
 421  * sources in order to safely close the descriptor or destroy the port. Closing 
 422  * the descriptor or port before the cancellation handler may result in a race 
 423  * condition. If a new descriptor is allocated with the same value as the 
 424  * recently closed descriptor while the source's event handler is still running, 
 425  * the event handler may read/write data to the wrong descriptor. 
 428  * The dispatch source to modify. 
 429  * The result of passing NULL in this parameter is undefined. 
 432  * The cancellation handler block to submit to the source's target queue. 
 435 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 436 DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
 
 438 dispatch_source_set_cancel_handler(dispatch_source_t source
, 
 439         dispatch_block_t cancel_handler
); 
 440 #endif /* __BLOCKS__ */ 
 443  * @function dispatch_source_set_cancel_handler_f 
 446  * Sets the cancellation handler function for the given dispatch source. 
 449  * See dispatch_source_set_cancel_handler() for more details. 
 452  * The dispatch source to modify. 
 453  * The result of passing NULL in this parameter is undefined. 
 456  * The cancellation handler function to submit to the source's target queue. 
 457  * The context parameter passed to the event handler function is the current 
 458  * context of the dispatch source at the time the handler call is made. 
 460 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 461 DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
 
 463 dispatch_source_set_cancel_handler_f(dispatch_source_t source
, 
 464         dispatch_function_t cancel_handler
); 
 467  * @function dispatch_source_cancel 
 470  * Asynchronously cancel the dispatch source, preventing any further invocation 
 471  * of its event handler block. 
 474  * Cancellation prevents any further invocation of the event handler block for 
 475  * the specified dispatch source, but does not interrupt an event handler 
 476  * block that is already in progress. 
 478  * The cancellation handler is submitted to the source's target queue once the 
 479  * the source's event handler has finished, indicating it is now safe to close 
 480  * the source's handle (i.e. file descriptor or mach port). 
 482  * See dispatch_source_set_cancel_handler() for more information. 
 485  * The dispatch source to be canceled. 
 486  * The result of passing NULL in this parameter is undefined. 
 488 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 489 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
 
 491 dispatch_source_cancel(dispatch_source_t source
); 
 494  * @function dispatch_source_testcancel 
 497  * Tests whether the given dispatch source has been canceled. 
 500  * The dispatch source to be tested. 
 501  * The result of passing NULL in this parameter is undefined. 
 504  * Non-zero if canceled and zero if not canceled. 
 506 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 507 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
 
 510 dispatch_source_testcancel(dispatch_source_t source
); 
 513  * @function dispatch_source_get_handle 
 516  * Returns the underlying system handle associated with this dispatch source. 
 519  * The result of passing NULL in this parameter is undefined. 
 522  * The return value should be interpreted according to the type of the dispatch 
 523  * source, and may be one of the following handles: 
 525  *  DISPATCH_SOURCE_TYPE_DATA_ADD:        n/a 
 526  *  DISPATCH_SOURCE_TYPE_DATA_OR:         n/a 
 527  *  DISPATCH_SOURCE_TYPE_MACH_SEND:       mach port (mach_port_t) 
 528  *  DISPATCH_SOURCE_TYPE_MACH_RECV:       mach port (mach_port_t) 
 529  *  DISPATCH_SOURCE_TYPE_MEMORYPRESSURE   n/a 
 530  *  DISPATCH_SOURCE_TYPE_PROC:            process identifier (pid_t) 
 531  *  DISPATCH_SOURCE_TYPE_READ:            file descriptor (int) 
 532  *  DISPATCH_SOURCE_TYPE_SIGNAL:          signal number (int) 
 533  *  DISPATCH_SOURCE_TYPE_TIMER:           n/a 
 534  *  DISPATCH_SOURCE_TYPE_VNODE:           file descriptor (int) 
 535  *  DISPATCH_SOURCE_TYPE_WRITE:           file descriptor (int) 
 537 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 538 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
 
 541 dispatch_source_get_handle(dispatch_source_t source
); 
 544  * @function dispatch_source_get_mask 
 547  * Returns the mask of events monitored by the dispatch source. 
 550  * The result of passing NULL in this parameter is undefined. 
 553  * The return value should be interpreted according to the type of the dispatch 
 554  * source, and may be one of the following flag sets: 
 556  *  DISPATCH_SOURCE_TYPE_DATA_ADD:        n/a 
 557  *  DISPATCH_SOURCE_TYPE_DATA_OR:         n/a 
 558  *  DISPATCH_SOURCE_TYPE_MACH_SEND:       dispatch_source_mach_send_flags_t 
 559  *  DISPATCH_SOURCE_TYPE_MACH_RECV:       n/a 
 560  *  DISPATCH_SOURCE_TYPE_MEMORYPRESSURE   dispatch_source_memorypressure_flags_t 
 561  *  DISPATCH_SOURCE_TYPE_PROC:            dispatch_source_proc_flags_t 
 562  *  DISPATCH_SOURCE_TYPE_READ:            n/a 
 563  *  DISPATCH_SOURCE_TYPE_SIGNAL:          n/a 
 564  *  DISPATCH_SOURCE_TYPE_TIMER:           dispatch_source_timer_flags_t 
 565  *  DISPATCH_SOURCE_TYPE_VNODE:           dispatch_source_vnode_flags_t 
 566  *  DISPATCH_SOURCE_TYPE_WRITE:           n/a 
 568 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 569 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
 
 572 dispatch_source_get_mask(dispatch_source_t source
); 
 575  * @function dispatch_source_get_data 
 578  * Returns pending data for the dispatch source. 
 581  * This function is intended to be called from within the event handler block. 
 582  * The result of calling this function outside of the event handler callback is 
 586  * The result of passing NULL in this parameter is undefined. 
 589  * The return value should be interpreted according to the type of the dispatch 
 590  * source, and may be one of the following: 
 592  *  DISPATCH_SOURCE_TYPE_DATA_ADD:        application defined data 
 593  *  DISPATCH_SOURCE_TYPE_DATA_OR:         application defined data 
 594  *  DISPATCH_SOURCE_TYPE_MACH_SEND:       dispatch_source_mach_send_flags_t 
 595  *  DISPATCH_SOURCE_TYPE_MACH_RECV:       n/a 
 596  *  DISPATCH_SOURCE_TYPE_MEMORYPRESSURE   dispatch_source_memorypressure_flags_t 
 597  *  DISPATCH_SOURCE_TYPE_PROC:            dispatch_source_proc_flags_t 
 598  *  DISPATCH_SOURCE_TYPE_READ:            estimated bytes available to read 
 599  *  DISPATCH_SOURCE_TYPE_SIGNAL:          number of signals delivered since 
 600  *                                            the last handler invocation 
 601  *  DISPATCH_SOURCE_TYPE_TIMER:           number of times the timer has fired 
 602  *                                            since the last handler invocation 
 603  *  DISPATCH_SOURCE_TYPE_VNODE:           dispatch_source_vnode_flags_t 
 604  *  DISPATCH_SOURCE_TYPE_WRITE:           estimated buffer space available 
 606 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 607 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
 
 610 dispatch_source_get_data(dispatch_source_t source
); 
 613  * @function dispatch_source_merge_data 
 616  * Merges data into a dispatch source of type DISPATCH_SOURCE_TYPE_DATA_ADD or 
 617  * DISPATCH_SOURCE_TYPE_DATA_OR and submits its event handler block to its 
 621  * The result of passing NULL in this parameter is undefined. 
 624  * The value to coalesce with the pending data using a logical OR or an ADD 
 625  * as specified by the dispatch source type. A value of zero has no effect 
 626  * and will not result in the submission of the event handler block. 
 628 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 629 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
 
 631 dispatch_source_merge_data(dispatch_source_t source
, unsigned long value
); 
 634  * @function dispatch_source_set_timer 
 637  * Sets a start time, interval, and leeway value for a timer source. 
 640  * Once this function returns, any pending source data accumulated for the 
 641  * previous timer values has been cleared; the next fire of the timer will 
 642  * occur at 'start', and every 'interval' nanoseconds thereafter until the 
 643  * timer source is canceled. 
 645  * Any fire of the timer may be delayed by the system in order to improve power 
 646  * consumption and system performance. The upper limit to the allowable delay 
 647  * may be configured with the 'leeway' argument, the lower limit is under the 
 648  * control of the system. 
 650  * For the initial timer fire at 'start', the upper limit to the allowable 
 651  * delay is set to 'leeway' nanoseconds. For the subsequent timer fires at 
 652  * 'start' + N * 'interval', the upper limit is MIN('leeway','interval'/2). 
 654  * The lower limit to the allowable delay may vary with process state such as 
 655  * visibility of application UI. If the specified timer source was created with 
 656  * a mask of DISPATCH_TIMER_STRICT, the system will make a best effort to 
 657  * strictly observe the provided 'leeway' value even if it is smaller than the 
 658  * current lower limit. Note that a minimal amount of delay is to be expected 
 659  * even if this flag is specified. 
 661  * The 'start' argument also determines which clock will be used for the timer: 
 662  * If 'start' is DISPATCH_TIME_NOW or was created with dispatch_time(3), the 
 663  * timer is based on mach_absolute_time(). If 'start' was created with 
 664  * dispatch_walltime(3), the timer is based on gettimeofday(3). 
 666  * Calling this function has no effect if the timer source has already been 
 670  * The start time of the timer. See dispatch_time() and dispatch_walltime() 
 671  * for more information. 
 674  * The nanosecond interval for the timer. Use DISPATCH_TIME_FOREVER for a 
 678  * The nanosecond leeway for the timer. 
 680 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
) 
 681 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
 
 683 dispatch_source_set_timer(dispatch_source_t source
, 
 684         dispatch_time_t start
, 
 689  * @function dispatch_source_set_registration_handler 
 692  * Sets the registration handler block for the given dispatch source. 
 695  * The registration handler (if specified) will be submitted to the source's 
 696  * target queue once the corresponding kevent() has been registered with the 
 697  * system, following the initial dispatch_resume() of the source. 
 699  * If a source is already registered when the registration handler is set, the 
 700  * registration handler will be invoked immediately. 
 703  * The dispatch source to modify. 
 704  * The result of passing NULL in this parameter is undefined. 
 707  * The registration handler block to submit to the source's target queue. 
 710 __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_4_3
) 
 711 DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
 
 713 dispatch_source_set_registration_handler(dispatch_source_t source
, 
 714         dispatch_block_t registration_handler
); 
 715 #endif /* __BLOCKS__ */ 
 718  * @function dispatch_source_set_registration_handler_f 
 721  * Sets the registration handler function for the given dispatch source. 
 724  * See dispatch_source_set_registration_handler() for more details. 
 727  * The dispatch source to modify. 
 728  * The result of passing NULL in this parameter is undefined. 
 731  * The registration handler function to submit to the source's target queue. 
 732  * The context parameter passed to the registration handler function is the 
 733  * current context of the dispatch source at the time the handler call is made. 
 735 __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_4_3
) 
 736 DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
 
 738 dispatch_source_set_registration_handler_f(dispatch_source_t source
, 
 739         dispatch_function_t registration_handler
);