2 * Copyright (c) 2008-2010 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_OBJECT__
22 #define __DISPATCH_OBJECT__
24 #ifndef __DISPATCH_INDIRECT__
25 #error "Please #include <dispatch/dispatch.h> instead of this file directly."
26 #include <dispatch/base.h> // for HeaderDoc
32 * @function dispatch_debug
35 * Programmatically log debug information about a dispatch object.
38 * Programmatically log debug information about a dispatch object. By default,
39 * the log output is sent to syslog at notice level. In the debug version of
40 * the library, the log output is sent to a file in /var/tmp.
41 * The log output destination can be configured via the LIBDISPATCH_LOG
42 * environment variable, valid values are: YES, NO, syslog, stderr, file.
45 * The object to introspect.
48 * The message to log above and beyond the introspection.
50 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
51 DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW
52 __attribute__((__format__(printf
,2,3)))
54 dispatch_debug(dispatch_object_t object
, const char *message
, ...);
56 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
57 DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW
58 __attribute__((__format__(printf
,2,0)))
60 dispatch_debugv(dispatch_object_t object
, const char *message
, va_list ap
);
63 * @function dispatch_retain
66 * Increment the reference count of a dispatch object.
69 * Calls to dispatch_retain() must be balanced with calls to
73 * The object to retain.
74 * The result of passing NULL in this parameter is undefined.
76 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
77 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
79 dispatch_retain(dispatch_object_t object
);
82 * @function dispatch_release
85 * Decrement the reference count of a dispatch object.
88 * A dispatch object is asynchronously deallocated once all references are
89 * released (i.e. the reference count becomes zero). The system does not
90 * guarantee that a given client is the last or only reference to a given
94 * The object to release.
95 * The result of passing NULL in this parameter is undefined.
97 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
98 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
100 dispatch_release(dispatch_object_t object
);
103 * @function dispatch_get_context
106 * Returns the application defined context of the object.
109 * The result of passing NULL in this parameter is undefined.
112 * The context of the object; may be NULL.
114 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
115 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_PURE DISPATCH_WARN_RESULT
118 dispatch_get_context(dispatch_object_t object
);
121 * @function dispatch_set_context
124 * Associates an application defined context with the object.
127 * The result of passing NULL in this parameter is undefined.
130 * The new client defined context for the object. This may be NULL.
133 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
134 DISPATCH_EXPORT DISPATCH_NOTHROW
//DISPATCH_NONNULL1
136 dispatch_set_context(dispatch_object_t object
, void *context
);
139 * @function dispatch_set_finalizer_f
142 * Set the finalizer function for a dispatch object.
145 * The dispatch object to modify.
146 * The result of passing NULL in this parameter is undefined.
149 * The finalizer function pointer.
152 * A dispatch object's finalizer will be invoked on the object's target queue
153 * after all references to the object have been released. This finalizer may be
154 * used by the application to release any resources associated with the object,
155 * such as freeing the object's context.
156 * The context parameter passed to the finalizer function is the current
157 * context of the dispatch object at the time the finalizer call is made.
159 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
160 DISPATCH_EXPORT DISPATCH_NOTHROW
//DISPATCH_NONNULL1
162 dispatch_set_finalizer_f(dispatch_object_t object
,
163 dispatch_function_t finalizer
);
166 * @function dispatch_suspend
169 * Suspends the invocation of blocks on a dispatch object.
172 * A suspended object will not invoke any blocks associated with it. The
173 * suspension of an object will occur after any running block associated with
174 * the object completes.
176 * Calls to dispatch_suspend() must be balanced with calls
177 * to dispatch_resume().
180 * The object to be suspended.
181 * The result of passing NULL in this parameter is undefined.
183 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
184 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
186 dispatch_suspend(dispatch_object_t object
);
189 * @function dispatch_resume
192 * Resumes the invocation of blocks on a dispatch object.
195 * The object to be resumed.
196 * The result of passing NULL in this parameter is undefined.
198 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
199 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
201 dispatch_resume(dispatch_object_t object
);