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>
26 DISPATCH_ASSUME_NONNULL_BEGIN
32 * Interposable introspection hooks for libdispatch.
35 * These hooks are only available in the introspection version of the library,
36 * loaded by running a process with the environment variable
37 * DYLD_LIBRARY_PATH=/usr/lib/system/introspection
43 * @function dispatch_introspection_hook_queue_create
46 * Interposable hook function called when a dispatch queue was created.
49 * The newly created dispatch queue.
52 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
55 dispatch_introspection_hook_queue_create(dispatch_queue_t queue
);
58 * @function dispatch_introspection_hook_queue_destroy
61 * Interposable hook function called when a dispatch queue is about to be
65 * The dispatch queue about to be destroyed.
68 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
71 dispatch_introspection_hook_queue_destroy(dispatch_queue_t queue
);
74 * @function dispatch_introspection_hook_queue_item_enqueue
77 * Interposable hook function called when an item is about to be enqueued onto
81 * The dispatch queue enqueued onto.
84 * The object about to be enqueued.
87 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
90 dispatch_introspection_hook_queue_item_enqueue(dispatch_queue_t queue
,
91 dispatch_object_t item
);
94 * @function dispatch_introspection_hook_queue_item_dequeue
97 * Interposable hook function called when an item was dequeued from a dispatch
101 * The dispatch queue dequeued from.
104 * The dequeued object.
107 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
110 dispatch_introspection_hook_queue_item_dequeue(dispatch_queue_t queue
,
111 dispatch_object_t item
);
114 * @function dispatch_introspection_hook_queue_item_complete
117 * Interposable hook function called when an item previously dequeued from a
118 * dispatch queue has completed processing.
121 * The object pointer value passed to this function must be treated as a value
122 * only. It is intended solely for matching up with an earlier call to a
123 * dequeue hook function and must NOT be dereferenced.
126 * Opaque dentifier for completed item. Must NOT be dereferenced.
129 __OSX_AVAILABLE_STARTING(__MAC_10_10
,__IPHONE_7_1
)
132 dispatch_introspection_hook_queue_item_complete(dispatch_object_t item
);
135 * @function dispatch_introspection_hook_queue_callout_begin
138 * Interposable hook function called when a client function is about to be
139 * called out to on a dispatch queue.
142 * The dispatch queue the callout is performed on.
145 * The context parameter passed to the function. For a callout to a block,
146 * this is a pointer to the block object.
149 * The client function about to be called out to. For a callout to a block,
150 * this is the block object's invoke function.
153 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
156 dispatch_introspection_hook_queue_callout_begin(dispatch_queue_t queue
,
157 void *_Nullable context
, dispatch_function_t function
);
160 * @function dispatch_introspection_hook_queue_callout_end
163 * Interposable hook function called after a client function has returned from
164 * a callout on a dispatch queue.
167 * The dispatch queue the callout was performed on.
170 * The context parameter passed to the function. For a callout to a block,
171 * this is a pointer to the block object.
174 * The client function that was called out to. For a callout to a block,
175 * this is the block object's invoke function.
178 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
181 dispatch_introspection_hook_queue_callout_end(dispatch_queue_t queue
,
182 void *_Nullable context
, dispatch_function_t function
);
186 DISPATCH_ASSUME_NONNULL_END