]> git.saurik.com Git - apple/libdispatch.git/blob - src/source_internal.h
libdispatch-84.5.5.tar.gz
[apple/libdispatch.git] / src / source_internal.h
1 /*
2 * Copyright (c) 2008-2009 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_SOURCE_INTERNAL__
28 #define __DISPATCH_SOURCE_INTERNAL__
29
30 #ifndef __DISPATCH_INDIRECT__
31 #error "Please #include <dispatch/dispatch.h> instead of this file directly."
32 #include <dispatch/base.h> // for HeaderDoc
33 #endif
34
35 struct dispatch_source_vtable_s {
36 DISPATCH_VTABLE_HEADER(dispatch_source_s);
37 };
38
39 extern const struct dispatch_source_vtable_s _dispatch_source_kevent_vtable;
40
41 struct dispatch_kevent_s {
42 TAILQ_ENTRY(dispatch_kevent_s) dk_list;
43 TAILQ_HEAD(, dispatch_source_s) dk_sources;
44 struct kevent dk_kevent;
45 };
46
47 typedef struct dispatch_kevent_s *dispatch_kevent_t;
48
49 struct dispatch_timer_source_s {
50 uint64_t target;
51 uint64_t start;
52 uint64_t interval;
53 uint64_t leeway;
54 uint64_t flags; // dispatch_timer_flags_t
55 };
56
57 #define DSF_CANCELED 1u // cancellation has been requested
58
59 struct dispatch_source_s {
60 DISPATCH_STRUCT_HEADER(dispatch_source_s, dispatch_source_vtable_s);
61 DISPATCH_QUEUE_HEADER;
62 // Instruments always copies DISPATCH_QUEUE_MIN_LABEL_SIZE, which is 64,
63 // so the remainder of the structure must be big enough
64 union {
65 char _ds_pad[DISPATCH_QUEUE_MIN_LABEL_SIZE];
66 struct {
67 char dq_label[8];
68 dispatch_kevent_t ds_dkev;
69
70 dispatch_source_handler_function_t ds_handler_func;
71 void *ds_handler_ctxt;
72
73 void *ds_cancel_handler;
74
75 unsigned int ds_is_level:1,
76 ds_is_adder:1,
77 ds_is_installed:1,
78 ds_needs_rearm:1,
79 ds_is_armed:1,
80 ds_is_legacy:1,
81 ds_cancel_is_block:1,
82 ds_handler_is_block:1;
83
84 unsigned int ds_atomic_flags;
85
86 unsigned long ds_data;
87 unsigned long ds_pending_data;
88 unsigned long ds_pending_data_mask;
89
90 TAILQ_ENTRY(dispatch_source_s) ds_list;
91
92 unsigned long ds_ident_hack;
93
94 struct dispatch_timer_source_s ds_timer;
95 };
96 };
97 };
98
99
100 void _dispatch_source_legacy_xref_release(dispatch_source_t ds);
101
102 #endif /* __DISPATCH_SOURCE_INTERNAL__ */