美文网首页
为什么dispatch_get_current_queue被废弃

为什么dispatch_get_current_queue被废弃

作者: natewang | 来源:发表于2018-03-24 12:02 被阅读79次

两个队列的背后很有可能是一个线程。在使用dispatch_get_current_queue来判断是否当前线程返回的可能不是你想要的结果。

 if (dispatch_get_current_queue() == queue) {
        block();
    } else {
        dispatch_sync(queue, block);
    }

特别这种代码,dispatch_sync到一个队列就锁死了。

相关文章

网友评论

      本文标题:为什么dispatch_get_current_queue被废弃

      本文链接:https://www.haomeiwen.com/subject/widqcftx.html