- (void)viewDidLoad
{
[super viewDidLoad];
dispatch_async(dispatch_queue_create("oneQueue", DISPATCH_QUEUE_SERIAL), ^
{
[self syncAction];
});
// CFRunLoopRun(); // 1
NSLog(@"mainQueue execut 1");
}
- (void)syncAction
{
dispatch_sync(dispatch_get_main_queue(), ^
{
// CFRunLoopStop(CFRunLoopGetCurrent());
NSLog(@"mainQueue execut 2"); // 2
});
}
If I commented CFRunLoopRun();
and CFRunLoopStop(CFRunLoopGetCurrent());
output:
mainQueue execut 1
mainQueue execut 2
but if I not comment CFRunLoopRun();
and CFRunLoopStop(CFRunLoopGetCurrent());
output:
mainQueue execut 2
mainQueue execut 1
I always think,if viewDidLoad
not excute complation, the mainQueue
will not execute
new function block,but why CFRunLoopRun
can make mainQueue
execute skip current function
and execute new block which added later by other asyncQueue
.
and when CFRunLoopStop(CFRunLoopGetCurren))
,viewDidLoad
continue execute .
what CFRunLoop
done?