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@
22 * IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
23 * which are subject to change in future releases of Mac OS X. Any applications
24 * relying on these interfaces WILL break.
27 #ifndef __DISPATCH_PRIVATE__
28 #define __DISPATCH_PRIVATE__
31 #include <TargetConditionals.h>
35 #include <mach/boolean.h>
36 #include <mach/mach.h>
37 #include <mach/message.h>
43 #include <sys/cdefs.h>
47 #ifndef __DISPATCH_BUILDING_DISPATCH__
48 #include <dispatch/dispatch.h>
50 #ifndef __DISPATCH_INDIRECT__
51 #define __DISPATCH_INDIRECT__
54 #include <dispatch/benchmark.h>
55 #include <dispatch/queue_private.h>
56 #include <dispatch/source_private.h>
57 #include <dispatch/mach_private.h>
58 #include <dispatch/data_private.h>
59 #include <dispatch/io_private.h>
60 #include <dispatch/layout_private.h>
62 #undef __DISPATCH_INDIRECT__
64 #endif /* !__DISPATCH_BUILDING_DISPATCH__ */
66 // <rdar://problem/9627726> Check that public and private dispatch headers match
67 #if DISPATCH_API_VERSION != 20140804 // Keep in sync with <dispatch/dispatch.h>
68 #error "Dispatch header mismatch between /usr/include and /usr/local/include"
74 * @function _dispatch_is_multithreaded
77 * Returns true if the current process has become multithreaded by the use
78 * of libdispatch functionality.
81 * This SPI is intended for use by low-level system components that need to
82 * ensure that they do not make a single-threaded process multithreaded, to
83 * avoid negatively affecting child processes of a fork (without exec).
85 * Such components must not use any libdispatch functionality if this function
89 * Boolean indicating whether the process has used libdispatch and become
92 __OSX_AVAILABLE_STARTING(__MAC_10_8
,__IPHONE_6_0
)
93 DISPATCH_EXPORT DISPATCH_NOTHROW
94 bool _dispatch_is_multithreaded(void);
97 * @function _dispatch_is_fork_of_multithreaded_parent
100 * Returns true if the current process is a child of a parent process that had
101 * become multithreaded by the use of libdispatch functionality at the time of
102 * fork (without exec).
105 * This SPI is intended for use by (rare) low-level system components that need
106 * to continue working on the child side of a fork (without exec) of a
107 * multithreaded process.
109 * Such components must not use any libdispatch functionality if this function
113 * Boolean indicating whether the parent process had used libdispatch and
114 * become multithreaded at the time of fork.
116 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
117 DISPATCH_EXPORT DISPATCH_NOTHROW
118 bool _dispatch_is_fork_of_multithreaded_parent(void);
121 * dispatch_time convenience macros
124 #define _dispatch_time_after_nsec(t) \
125 dispatch_time(DISPATCH_TIME_NOW, (t))
126 #define _dispatch_time_after_usec(t) \
127 dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_USEC)
128 #define _dispatch_time_after_msec(t) \
129 dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_MSEC)
130 #define _dispatch_time_after_sec(t) \
131 dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_SEC)
134 * SPI for CoreFoundation/Foundation/libauto ONLY
137 #define DISPATCH_COCOA_COMPAT (TARGET_OS_MAC || TARGET_OS_WIN32)
139 #if DISPATCH_COCOA_COMPAT
142 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
143 DISPATCH_EXPORT DISPATCH_CONST DISPATCH_WARN_RESULT DISPATCH_NOTHROW
145 _dispatch_get_main_queue_port_4CF(void);
147 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
148 DISPATCH_EXPORT DISPATCH_NOTHROW
150 _dispatch_main_queue_callback_4CF(mach_msg_header_t
*msg
);
151 #elif TARGET_OS_WIN32
152 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
153 DISPATCH_EXPORT DISPATCH_NOTHROW
155 _dispatch_get_main_queue_handle_4CF(void);
157 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
158 DISPATCH_EXPORT DISPATCH_NOTHROW
160 _dispatch_main_queue_callback_4CF(void);
161 #endif // TARGET_OS_WIN32
163 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
164 DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
167 _dispatch_runloop_root_queue_create_4CF(const char *label
, unsigned long flags
);
170 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
171 DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW
173 _dispatch_runloop_root_queue_get_port_4CF(dispatch_queue_t queue
);
176 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
177 DISPATCH_EXPORT DISPATCH_NOTHROW
179 _dispatch_runloop_root_queue_wakeup_4CF(dispatch_queue_t queue
);
181 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
182 DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW
184 _dispatch_runloop_root_queue_perform_4CF(dispatch_queue_t queue
);
186 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
187 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
189 _dispatch_source_set_runloop_timer_4CF(dispatch_source_t source
,
190 dispatch_time_t start
, uint64_t interval
, uint64_t leeway
);
192 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
194 void (*dispatch_begin_thread_4GC
)(void);
196 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
198 void (*dispatch_end_thread_4GC
)(void);
199 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
201 void *(*_dispatch_begin_NSAutoReleasePool
)(void);
203 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
205 void (*_dispatch_end_NSAutoReleasePool
)(void *);
207 #endif /* DISPATCH_COCOA_COMPAT */
211 #endif // __DISPATCH_PRIVATE__