Reputation: 1232
If each UIApplication
initializes a RunLoop like this on the main thread
void CFRunLoopRun(void) { /* DOES CALLOUT */
int32_t result;
do {
result = CFRunLoopRunSpecific(CFRunLoopGetCurrent(), kCFRunLoopDefaultMode, 1.0e10, false);
CHECK_FOR_FORK();
} while (kCFRunLoopRunStopped != result && kCFRunLoopRunFinished != result);
}
Why it doesn't block the whole execution since it is an infinite loop? How could an infinite loop and my code on the main thread work together on a single thread without context switching?
Upvotes: 2
Views: 305
Reputation: 299663
It does block the current thread. However, part of what CFRunLoopRunSpecific
does is call your code on that thread. When you return, it goes back to CFRunLoopRunSpecific
, which then calls other code.
Upvotes: 2