2 * Copyright (c) 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_INTROSPECTION__
22 #define __DISPATCH_INTROSPECTION__
24 #include <dispatch/dispatch.h>
30 * Interposable introspection hooks for libdispatch.
33 * These hooks are only available in the introspection version of the library,
34 * loaded by running a process with the environment variable
35 * DYLD_LIBRARY_PATH=/usr/lib/system/introspection
41 * @function dispatch_introspection_hook_queue_create
44 * Interposable hook function called when a dispatch queue was created.
47 * The newly created dispatch queue.
50 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
53 dispatch_introspection_hook_queue_create(dispatch_queue_t queue
);
56 * @function dispatch_introspection_hook_queue_destroy
59 * Interposable hook function called when a dispatch queue is about to be
63 * The dispatch queue about to be destroyed.
66 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
69 dispatch_introspection_hook_queue_destroy(dispatch_queue_t queue
);
72 * @function dispatch_introspection_hook_queue_item_enqueue
75 * Interposable hook function called when an item is about to be enqueued onto
79 * The dispatch queue enqueued onto.
82 * The object about to be enqueued.
85 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
88 dispatch_introspection_hook_queue_item_enqueue(dispatch_queue_t queue
,
89 dispatch_object_t item
);
92 * @function dispatch_introspection_hook_queue_item_dequeue
95 * Interposable hook function called when an item was dequeued from a dispatch
99 * The dispatch queue dequeued from.
102 * The dequeued object.
105 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
108 dispatch_introspection_hook_queue_item_dequeue(dispatch_queue_t queue
,
109 dispatch_object_t item
);
112 * @function dispatch_introspection_hook_queue_item_complete
115 * Interposable hook function called when an item previously dequeued from a
116 * dispatch queue has completed processing.
119 * The object pointer value passed to this function must be treated as a value
120 * only. It is intended solely for matching up with an earlier call to a
121 * dequeue hook function and must NOT be dereferenced.
124 * Opaque dentifier for completed item. Must NOT be dereferenced.
127 __OSX_AVAILABLE_STARTING(__MAC_10_10
,__IPHONE_7_1
)
130 dispatch_introspection_hook_queue_item_complete(dispatch_object_t item
);
133 * @function dispatch_introspection_hook_queue_callout_begin
136 * Interposable hook function called when a client function is about to be
137 * called out to on a dispatch queue.
140 * The dispatch queue the callout is performed on.
143 * The context parameter passed to the function. For a callout to a block,
144 * this is a pointer to the block object.
147 * The client function about to be called out to. For a callout to a block,
148 * this is the block object's invoke function.
151 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
154 dispatch_introspection_hook_queue_callout_begin(dispatch_queue_t queue
,
155 void *context
, dispatch_function_t function
);
158 * @function dispatch_introspection_hook_queue_callout_end
161 * Interposable hook function called after a client function has returned from
162 * a callout on a dispatch queue.
165 * The dispatch queue the callout was performed on.
168 * The context parameter passed to the function. For a callout to a block,
169 * this is a pointer to the block object.
172 * The client function that was called out to. For a callout to a block,
173 * this is the block object's invoke function.
176 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
179 dispatch_introspection_hook_queue_callout_end(dispatch_queue_t queue
,
180 void *context
, dispatch_function_t function
);