Ege*_*nar 1 exc-bad-access dispatch grand-central-dispatch ios dispatch-async
我们最近修改了我们的线程机制,支持dispatch_async在大多数地方使用'(在做了很多关于NSOperation和dispatch_async的阅读之后)*.然后我们的代码开始在代码的各个部分与EXC_BAD_ACCESS崩溃,总是在dispatch_async(queue,...)部分,没有明确的模式.通常在20分钟后发生--2小时.
我们的dispatch_async块用于通知听众,如下所示:
NSMutableSet *_listeners; // Initialised elsewhere and filled with interested listeners
void(^block)(id listener); // Block to execute
@synchronized(_listeners) {
for (id listener in _listeners) {
dispatch_async_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); // We used different queues for different listeners, but showing only one type of queue here for brevity
dispatch_async(queue, ^{ // CRASHING LINE
block(listener);
});
}
}Run Code Online (Sandbox Code Playgroud)
常见的症状是:
(这是一个自我回答的问题)
*我们喜欢简单dispatch_async,不需要阻止/依赖功能,NSOperationQueue我们很快就会转向C++,所以想保持低水平.
| 归档时间: |
|
| 查看次数: |
829 次 |
| 最近记录: |