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_SEMAPHORE_INTERNAL__
28 #define __DISPATCH_SEMAPHORE_INTERNAL__
30 struct dispatch_queue_s
;
32 #define DISPATCH_SEMAPHORE_HEADER(cls, ns) \
33 DISPATCH_OBJECT_HEADER(cls); \
34 long volatile ns##_value; \
35 _os_semaphore_t ns##_sema
37 struct dispatch_semaphore_header_s
{
38 DISPATCH_SEMAPHORE_HEADER(semaphore
, dsema
);
41 DISPATCH_CLASS_DECL(semaphore
);
42 struct dispatch_semaphore_s
{
43 DISPATCH_SEMAPHORE_HEADER(semaphore
, dsema
);
47 DISPATCH_CLASS_DECL(group
);
48 struct dispatch_group_s
{
49 DISPATCH_SEMAPHORE_HEADER(group
, dg
);
50 int volatile dg_waiters
;
51 struct dispatch_continuation_s
*volatile dg_notify_head
;
52 struct dispatch_continuation_s
*volatile dg_notify_tail
;
56 struct dispatch_semaphore_header_s
*_dsema_hdr
;
57 struct dispatch_semaphore_s
*_dsema
;
58 struct dispatch_group_s
*_dg
;
60 dispatch_semaphore_t _objc_dsema
;
61 dispatch_group_t _objc_dg
;
63 } dispatch_semaphore_class_t
__attribute__((__transparent_union__
));
65 dispatch_group_t
_dispatch_group_create_and_enter(void);
66 void _dispatch_group_dispose(dispatch_object_t dou
);
67 size_t _dispatch_group_debug(dispatch_object_t dou
, char *buf
,
70 void _dispatch_semaphore_dispose(dispatch_object_t dou
);
71 size_t _dispatch_semaphore_debug(dispatch_object_t dou
, char *buf
,