1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
| int CFRunLoopRunSpecific(runloop, modeName, seconds, stopAfterHandle) {
CFRunLoopModeRef currentMode = __CFRunLoopFindMode(runloop, modeName, false); if (__CFRunLoopModeIsEmpty(currentMode)) return;
__CFRunLoopDoObservers(runloop, currentMode, kCFRunLoopEntry);
__CFRunLoopRun(runloop, currentMode, seconds, returnAfterSourceHandled) {
Boolean sourceHandledThisLoop = NO; int retVal = 0; do {
__CFRunLoopDoObservers(runloop, currentMode, kCFRunLoopBeforeTimers); __CFRunLoopDoObservers(runloop, currentMode, kCFRunLoopBeforeSources); __CFRunLoopDoBlocks(runloop, currentMode);
sourceHandledThisLoop = __CFRunLoopDoSources0(runloop, currentMode, stopAfterHandle); __CFRunLoopDoBlocks(runloop, currentMode);
if (__Source0DidDispatchPortLastTime) { Boolean hasMsg = __CFRunLoopServiceMachPort(dispatchPort, &msg) if (hasMsg) goto handle_msg; }
if (!sourceHandledThisLoop) { __CFRunLoopDoObservers(runloop, currentMode, kCFRunLoopBeforeWaiting); }
mach_msg(msg, MACH_RCV_MSG, port);
__CFRunLoopDoObservers(runloop, currentMode, kCFRunLoopAfterWaiting);
handle_msg:
if (msg_is_timer) { __CFRunLoopDoTimers(runloop, currentMode, mach_absolute_time()) }
else if (msg_is_dispatch) { __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__(msg); }
else { CFRunLoopSourceRef source1 = __CFRunLoopModeFindSourceForMachPort(runloop, currentMode, livePort); sourceHandledThisLoop = __CFRunLoopDoSource1(runloop, currentMode, source1, msg); if (sourceHandledThisLoop) { mach_msg(reply, MACH_SEND_MSG, reply); } }
__CFRunLoopDoBlocks(runloop, currentMode);
if (sourceHandledThisLoop && stopAfterHandle) { retVal = kCFRunLoopRunHandledSource; } else if (timeout) { retVal = kCFRunLoopRunTimedOut; } else if (__CFRunLoopIsStopped(runloop)) { retVal = kCFRunLoopRunStopped; } else if (__CFRunLoopModeIsEmpty(runloop, currentMode)) { retVal = kCFRunLoopRunFinished; }
} while (retVal == 0); }
__CFRunLoopDoObservers(rl, currentMode, kCFRunLoopExit); }
|