在 GCD (iOS) 中调度屏障队列



我正在应用程序中创建多个并发队列。 dispatch_barrier_sync用于修改共享资源。

dispatch_barrier_sync是只在当前队列中阻止并行执行还是跨所有队列阻止并行执行?

例如,假设我有 3 个自定义并发队列"A"、"B"和"C"。 如果我向"A"队列提交一个dispatch_barrier_sync块,它会阻止从"B"和"C"并行执行吗?还是仅在"A"中?

只有 A. 确切地说,它不会阻止任何东西。它只会等到 A 中的所有任务都完成。B 和 C 将像往常一样工作,并且可以调用它们的块。

https://developer.apple.com/library/mac/documentation/performance/reference/gcd_libdispatch_ref/Reference/reference.html#//apple_ref/c/func/dispatch_barrier_sync

最新更新