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>
61 #undef __DISPATCH_INDIRECT__
63 #endif /* !__DISPATCH_BUILDING_DISPATCH__ */
65 // <rdar://problem/9627726> Check that public and private dispatch headers match
66 #if DISPATCH_API_VERSION != 20130520 // Keep in sync with <dispatch/dispatch.h>
67 #error "Dispatch header mismatch between /usr/include and /usr/local/include"
73 * @function _dispatch_is_multithreaded
76 * Returns true if the current process has become multithreaded by the use
77 * of libdispatch functionality.
80 * This SPI is intended for use by low-level system components that need to
81 * ensure that they do not make a single-threaded process multithreaded, to
82 * avoid negatively affecting child processes of a fork (without exec).
84 * Such components must not use any libdispatch functionality if this function
88 * Boolean indicating whether the process has used libdispatch and become
91 __OSX_AVAILABLE_STARTING(__MAC_10_8
,__IPHONE_6_0
)
92 DISPATCH_EXPORT DISPATCH_NOTHROW
93 bool _dispatch_is_multithreaded(void);
96 * @function _dispatch_is_fork_of_multithreaded_parent
99 * Returns true if the current process is a child of a parent process that had
100 * become multithreaded by the use of libdispatch functionality at the time of
101 * fork (without exec).
104 * This SPI is intended for use by (rare) low-level system components that need
105 * to continue working on the child side of a fork (without exec) of a
106 * multithreaded process.
108 * Such components must not use any libdispatch functionality if this function
112 * Boolean indicating whether the parent process had used libdispatch and
113 * become multithreaded at the time of fork.
115 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
116 DISPATCH_EXPORT DISPATCH_NOTHROW
117 bool _dispatch_is_fork_of_multithreaded_parent(void);
120 * dispatch_time convenience macros
123 #define _dispatch_time_after_nsec(t) \
124 dispatch_time(DISPATCH_TIME_NOW, (t))
125 #define _dispatch_time_after_usec(t) \
126 dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_USEC)
127 #define _dispatch_time_after_msec(t) \
128 dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_MSEC)
129 #define _dispatch_time_after_sec(t) \
130 dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_SEC)
133 * SPI for CoreFoundation/Foundation/libauto ONLY
136 #define DISPATCH_COCOA_COMPAT (TARGET_OS_MAC || TARGET_OS_WIN32)
138 #if DISPATCH_COCOA_COMPAT
141 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
142 DISPATCH_EXPORT DISPATCH_CONST DISPATCH_WARN_RESULT DISPATCH_NOTHROW
144 _dispatch_get_main_queue_port_4CF(void);
146 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
147 DISPATCH_EXPORT DISPATCH_NOTHROW
149 _dispatch_main_queue_callback_4CF(mach_msg_header_t
*msg
);
150 #elif TARGET_OS_WIN32
151 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
152 DISPATCH_EXPORT DISPATCH_NOTHROW
154 _dispatch_get_main_queue_handle_4CF(void);
156 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
157 DISPATCH_EXPORT DISPATCH_NOTHROW
159 _dispatch_main_queue_callback_4CF(void);
160 #endif // TARGET_OS_WIN32
162 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
163 DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
166 _dispatch_runloop_root_queue_create_4CF(const char *label
, unsigned long flags
);
169 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
170 DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW
172 _dispatch_runloop_root_queue_get_port_4CF(dispatch_queue_t queue
);
175 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
176 DISPATCH_EXPORT DISPATCH_NOTHROW
178 _dispatch_runloop_root_queue_wakeup_4CF(dispatch_queue_t queue
);
180 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
181 DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW
183 _dispatch_runloop_root_queue_perform_4CF(dispatch_queue_t queue
);
185 __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
)
186 DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
188 _dispatch_source_set_runloop_timer_4CF(dispatch_source_t source
,
189 dispatch_time_t start
, uint64_t interval
, uint64_t leeway
);
191 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
193 void (*dispatch_begin_thread_4GC
)(void);
195 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
197 void (*dispatch_end_thread_4GC
)(void);
198 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
200 void *(*_dispatch_begin_NSAutoReleasePool
)(void);
202 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_4_0
)
204 void (*_dispatch_end_NSAutoReleasePool
)(void *);
206 #endif /* DISPATCH_COCOA_COMPAT */
210 #endif // __DISPATCH_PRIVATE__