1 .\" Copyright (c) 2008-2009 Apple Inc. All rights reserved.
7 .Nd General manipulation of dispatch objects
9 .Fd #include <dispatch/dispatch.h>
12 .Fa "dispatch_object_t object"
16 .Fa "dispatch_object_t object"
20 .Fa "dispatch_object_t object"
24 .Fa "dispatch_object_t object"
27 .Fo dispatch_get_context
28 .Fa "dispatch_object_t object"
31 .Fo dispatch_set_context
32 .Fa "dispatch_object_t object"
36 .Fo dispatch_set_finalizer_f
37 .Fa "dispatch_object_t object"
38 .Fa "dispatch_function_t finalizer"
41 Dispatch objects share functions for coordinating memory management, suspension,
42 cancellation and context pointers. While all dispatch objects are retainable,
43 not all objects support suspension, context pointers or finalizers (currently
44 only queues and sources support these additional interfaces).
46 Objects returned by creation functions in the dispatch framework may be
47 uniformly retained and released with the functions
53 The dispatch framework does not guarantee that any given client has the last or
54 only reference to a given object. Objects may be retained internally by the
57 The invocation of blocks on dispatch queues or dispatch sources may be suspended
58 or resumed with the functions
63 The dispatch framework always checks the suspension status before executing a
64 block, but such changes never affect a block during execution (non-preemptive).
65 Therefore the suspension of an object is asynchronous, unless it is performed
66 from the context of the target queue for the given object.
67 The result of suspending or resuming an object that is not a dispatch queue or
68 a dispatch source is undefined.
71 suspension applies to all aspects of the dispatch object life cycle, including
72 the finalizer function and cancellation handler. Therefore it is important to
77 such that the dispatch object is fully resumed when the last reference is
78 released. The result of releasing all references to a dispatch object while in
79 a suspended state is undefined.
81 Dispatch queues and sources support supplemental context pointers. The value of
82 the context point may be retrieved and updated with
83 .Fn dispatch_get_context
85 .Fn dispatch_set_context
88 .Fn dispatch_set_finalizer_f
89 specifies an optional per-object finalizer function to that is invoked
90 asynchronously when the last reference to the object is released. This gives the
91 application an opportunity to free the context data associated with the object.
93 The result of getting or setting the context of an object that is not a
94 dispatch queue or a dispatch source is undefined.
96 .Xr dispatch_group_create 3 ,
97 .Xr dispatch_queue_create 3 ,
98 .Xr dispatch_semaphore_create 3 ,
99 .Xr dispatch_source_create 3