]> git.saurik.com Git - apple/libdispatch.git/blob - src/semaphore_internal.h
libdispatch-703.50.37.tar.gz
[apple/libdispatch.git] / src / semaphore_internal.h
1 /*
2 * Copyright (c) 2008-2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
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
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
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.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21 /*
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.
25 */
26
27 #ifndef __DISPATCH_SEMAPHORE_INTERNAL__
28 #define __DISPATCH_SEMAPHORE_INTERNAL__
29
30 struct dispatch_queue_s;
31
32 #define DISPATCH_SEMAPHORE_HEADER(cls, ns) \
33 DISPATCH_OBJECT_HEADER(cls); \
34 long volatile ns##_value; \
35 _os_semaphore_t ns##_sema
36
37 struct dispatch_semaphore_header_s {
38 DISPATCH_SEMAPHORE_HEADER(semaphore, dsema);
39 };
40
41 DISPATCH_CLASS_DECL(semaphore);
42 struct dispatch_semaphore_s {
43 DISPATCH_SEMAPHORE_HEADER(semaphore, dsema);
44 long dsema_orig;
45 };
46
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;
53 };
54
55 typedef union {
56 struct dispatch_semaphore_header_s *_dsema_hdr;
57 struct dispatch_semaphore_s *_dsema;
58 struct dispatch_group_s *_dg;
59 #if USE_OBJC
60 dispatch_semaphore_t _objc_dsema;
61 dispatch_group_t _objc_dg;
62 #endif
63 } dispatch_semaphore_class_t __attribute__((__transparent_union__));
64
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,
68 size_t bufsiz);
69
70 void _dispatch_semaphore_dispose(dispatch_object_t dou);
71 size_t _dispatch_semaphore_debug(dispatch_object_t dou, char *buf,
72 size_t bufsiz);
73
74 #endif