]> git.saurik.com Git - apple/cf.git/blame - CFRunLoopPriv.h
CF-476.18.tar.gz
[apple/cf.git] / CFRunLoopPriv.h
CommitLineData
bd5b749c
A
1/*
2 * Copyright (c) 2008 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/* CFRunLoopPriv.h
24 Copyright (c) 2006-2007, Apple Inc. All rights reserved.
25*/
26
27#if (DEPLOYMENT_TARGET_MACOSX || 0)
28
29/* -------- -------- -------- -------- -------- -------- -------- -------- */
30
31#import "CFObject.h"
32#include <CoreFoundation/CFRunLoop.h>
33#include <CoreFoundation/CFMachPort.h>
34#include <CoreFoundation/CFSocket.h>
35#include <CoreFoundation/CFArray.h>
36#include <CoreFoundation/CFBag.h>
37#include <mach/mach.h>
38#include <sys/event.h>
39#include <pthread.h>
40
41@class CFRunLoopSourceSet;
42typedef CFRunLoopSourceContext CFRunLoopSourceContext0;
43typedef CFMachPortContext CFRunLoopMachPortContext;
44typedef CFSocketContext CFRunLoopSocketContext;
45
46/* -------- -------- -------- -------- -------- -------- -------- -------- */
47
48@interface CFRunLoopSource : CFObject {
49 uint8_t _cfruntime_[8]; // large enough for 32-bit or 64-bit
50 int _kq;
51 mach_port_t _portset;
52 mach_port_t _port;
53 CFIndex _order;
54 uint8_t _invalid;
55 uint8_t _firing;
56 uint8_t _ownsPort;
57 uint8_t _async;
58}
59
60- (int)kqueue;
61- (mach_port_t)machPortSet;
62- (mach_port_t)machPort;
63
64- (void)setOrder:(CFIndex)o;
65- (CFIndex)order;
66
67- (void)setAsyncStrategy:(uint8_t)s;
68- (uint8_t)asyncStrategy;
69
70- (void)perform:(mach_msg_header_t *)msg;
71
72- (void)invalidate;
73- (Boolean)isValid;
74
75- (void)noteAddedToSourceSet:(CFRunLoopSourceSet *)ss;
76- (void)noteRemovedFromSourceSet:(CFRunLoopSourceSet *)ss;
77
78- (CFStringRef)copyPartialDebugDescription; // subclasses override
79- (CFStringRef)copyDebugDescription;
80
81@end
82
83@interface CFRunLoopVersion0SourceCFRef : CFRunLoopSource {
84 CFRunLoopSourceContext0 _context;
85}
86
87- (Boolean)setContext:(CFRunLoopSourceContext0)c;
88- (CFRunLoopSourceContext0)context;
89
90- (void)markReady;
91- (void)handle;
92
93- (void)scheduleInRunLoop:(CFRunLoopRef)rl mode:(CFStringRef)n;
94- (void)cancelFromRunLoop:(CFRunLoopRef)rl mode:(CFStringRef)n;
95
96@end
97
98@interface CFRunLoopVersion1SourceCFRef : CFRunLoopSource {
99 CFRunLoopSourceContext1 _context;
100}
101
102- (Boolean)setContext:(CFRunLoopSourceContext1)c;
103- (CFRunLoopSourceContext1)context;
104
105- (void)markReady;
106- (void)handle:(mach_msg_header_t *)msg;
107
108@end
109
110/* -------- -------- -------- -------- -------- -------- -------- -------- */
111
112@interface CFRunLoopTimerSource : CFRunLoopSource {
113 CFAbsoluteTime _fireAT;
114 CFTimeInterval _interval;
115}
116
117- (void)setFireTime:(CFAbsoluteTime)at;
118- (CFAbsoluteTime)fireTime;
119
120- (void)setInterval:(CFTimeInterval)i;
121- (CFTimeInterval)interval;
122
123- (void)handle;
124
125@end
126
127@interface CFRunLoopTimerSourceCFRef : CFRunLoopTimerSource {
128 void *_function;
129 CFRunLoopTimerContext _context;
130}
131
132- (void)setFunction:(void *)f;
133- (void *)function;
134
135- (Boolean)setContext:(CFRunLoopTimerContext)c;
136- (CFRunLoopTimerContext)context;
137
138@end
139
140/* -------- -------- -------- -------- -------- -------- -------- -------- */
141
142@interface CFRunLoopMachPortSource : CFRunLoopSource {
143 mach_port_t _notifyPort;
144 mach_port_t _oldNotifyPort;
145}
146
147+ (id)newWithPort:(mach_port_t)p;
148
149- (void)handle:(mach_msg_header_t *)msg;
150
151@end
152
153@interface CFRunLoopMachPortSourceCFRef : CFRunLoopMachPortSource {
154 void *_function;
155 CFRunLoopMachPortContext _context;
156 void *_invalidation;
157}
158
159- (void)setFunction:(void *)f;
160- (void *)function;
161
162- (Boolean)setContext:(CFRunLoopMachPortContext)c;
163- (CFRunLoopMachPortContext)context;
164
165- (void)setInvalidationFunction:(void *)f;
166- (void *)invalidationFunction;
167
168@end
169
170/* -------- -------- -------- -------- -------- -------- -------- -------- */
171
172@interface CFRunLoopKEventSource : CFRunLoopSource {
173 struct kevent _filter;
174}
175
176- (Boolean)setFilter:(struct kevent)kev;
177- (struct kevent)filter;
178
179- (void)handle:(struct kevent *)kev;
180
181@end
182
183/* -------- -------- -------- -------- -------- -------- -------- -------- */
184
185@interface CFRunLoopSignalSource : CFRunLoopSource {
186 int _signal;
187}
188
189- (Boolean)setSignal:(int)sig;
190- (int)signal;
191
192- (long)poll;
193
194- (void)handle:(long)n;
195
196@end
197
198/* -------- -------- -------- -------- -------- -------- -------- -------- */
199
200@interface CFRunLoopProcessDeathSource : CFRunLoopSource {
201 int _pid;
202}
203
204- (Boolean)setProcessID:(int)pid;
205- (int)processID;
206
207- (void)handle;
208
209@end
210
211/* -------- -------- -------- -------- -------- -------- -------- -------- */
212
213@interface CFRunLoopSocketSource : CFRunLoopSource {
214 int _socket;
215 uint8_t _ownsSocket;
216 uint8_t _enabledR;
217 uint8_t _enabledW;
218}
219
220+ (id)newWithSocket:(int)s;
221
222- (int)socket;
223- (CFDataRef)copyLocalAddress;
224- (CFDataRef)copyRemoteAddress;
225
226- (void)setReadEventsEnabled:(Boolean)b;
227- (Boolean)readEventsEnabled;
228
229- (void)setWriteEventsEnabled:(Boolean)b;
230- (Boolean)writeEventsEnabled;
231
232- (void)handleReadability:(CFIndex)amt endOfFile:(Boolean)b;
233- (void)performRead:(struct kevent *)kev;
234
235- (void)handleWritability:(CFIndex)amt endOfFile:(Boolean)b;
236- (void)performWrite:(struct kevent *)kev;
237
238@end
239
240@interface CFRunLoopSocketSourceCFRef : CFRunLoopSocketSource {
241 void *_function;
242 CFRunLoopSocketContext _context;
243 uint8_t _callbacks;
244 uint8_t _flags;
245 uint8_t _disabled;
246}
247
248- (void)setFunction:(void *)f;
249- (void *)function;
250
251- (Boolean)setContext:(CFRunLoopSocketContext)c;
252- (CFRunLoopSocketContext)context;
253
254- (void)setCallBackTypes:(uint8_t)f;
255- (uint8_t)callBackTypes;
256
257- (void)setFlags:(uint8_t)f;
258- (uint8_t)flags;
259
260- (void)setDisabledFlags:(uint8_t)f;
261- (uint8_t)disabledFlags;
262
263- (Boolean)handleAcceptError:(int)err;
264- (Boolean)handleReadError:(int)err;
265
266@end
267
268/* -------- -------- -------- -------- -------- -------- -------- -------- */
269
270@interface CFRunLoopObserver : CFRunLoopSource {
271}
272
273- (void)observeEntry:(CFRunLoopSourceSet *)ss;
274- (void)observeBeforeWaiting:(CFRunLoopSourceSet *)ss;
275- (void)observeAfterWaiting:(CFRunLoopSourceSet *)ss;
276- (void)observeExit:(CFRunLoopSourceSet *)ss;
277
278@end
279
280@interface CFRunLoopObserverCFRef : CFRunLoopObserver {
281 void *_function;
282 CFRunLoopObserverContext _context;
283 CFOptionFlags _activities;
284 uint8_t _oneshot;
285}
286
287- (void)setFunction:(void *)f;
288- (void *)function;
289
290- (Boolean)setContext:(CFRunLoopObserverContext)c;
291- (CFRunLoopObserverContext)context;
292
293- (void)setActivities:(CFOptionFlags)a;
294- (CFOptionFlags)activities;
295
296- (void)setOneshot:(Boolean)b;
297- (Boolean)oneshot;
298
299@end
300
301/* -------- -------- -------- -------- -------- -------- -------- -------- */
302
303@interface CFRunLoopSourceSet : CFRunLoopObserver {
304 CFMutableBagRef _sources;
305 CFStringRef _name;
306 pthread_t _thread;
307 CFMutableArrayRef _observers[4];
308 CFRunLoopTimerSource *_timeoutTimer;
309 CFRunLoopMachPortSource *_wakeupPort;
310 uint8_t _stopped;
311 uint8_t _waiting;
312}
313
314+ (void)removeSourceFromAllSets:(CFRunLoopSource *)src;
315
316- (void)setName:(CFStringRef)n;
317- (CFStringRef)name;
318
319- (void)setAffineThread:(pthread_t)t;
320- (pthread_t)affineThread;
321
322- (Boolean)containsObserver:(CFRunLoopObserver *)o;
323- (void)addObserver:(CFRunLoopObserver *)o activities:(CFRunLoopActivity)a;
324- (void)removeObserver:(CFRunLoopObserver *)o activities:(CFRunLoopActivity)a;
325
326- (Boolean)containsSource:(CFRunLoopSource *)src;
327- (void)addSource:(CFRunLoopSource *)src;
328- (void)removeSource:(CFRunLoopSource *)src;
329
330- (void)forEachSource:(Boolean (*)(CFRunLoopSource *, void *))f context:(void *)c;
331
332- (void)stop;
333- (void)wakeup;
334- (Boolean)isWaiting;
335- (Boolean)isEmpty;
336- (Boolean)hasInputAvailable;
337
338- (int32_t)serviceUntil:(CFAbsoluteTime)at handleOne:(Boolean)handleOne;
339
340@end
341
342/* -------- -------- -------- -------- -------- -------- -------- -------- */
343
344@interface CFRunLoopCFRef : CFObject {
345 uint8_t _cfruntime_[8]; // large enough for 32-bit or 64-bit
346 pthread_t _thread;
347 void *_counterpart;
348 CFMutableArrayRef _sourceSets;
349 CFRunLoopSourceSet *_currentSet;
350 uint8_t _invalid;
351}
352
353- (void)setAffineThread:(pthread_t)t;
354- (pthread_t)affineThread;
355
356- (void)setCounterpart:(void *)c;
357- (void *)counterpart;
358
359- (void)invalidate;
360- (Boolean)isValid;
361
362- (CFArrayRef)copySourceSets;
363
364- (void)setCurrentSourceSet:(CFRunLoopSourceSet *)ss;
365- (CFRunLoopSourceSet *)currentSourceSet;
366
367- (CFRunLoopSourceSet *)lookupSourceSetWithName:(CFStringRef)n;
368- (CFRunLoopSourceSet *)lookupOrCreateSourceSetWithName:(CFStringRef)n;
369
370- (CFStringRef)copyDebugDescription;
371
372@end
373
374/* -------- -------- -------- -------- -------- -------- -------- -------- */
375
376#endif
377