在典型的dispatch_async
执行中:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
// ...
dispatch_async(dispatch_get_main_queue(), ^{
// ...
});
});
仅限制仅运行一个块:
if (_loadingFromServer) return;
_loadingFromServer = YES;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
// ...
dispatch_async(dispatch_get_main_queue(), ^{
// ...
_loadingFromServer = NO;
});
});
有没有办法在不使用_loadingFromServer
标志的情况下检查异步块的运行位置?
dispatch_queue_set_specific
在这种情况下有用吗?