NSOperationQueue 和并发操作
正如 NSOperationQueue 类参考所述: 在 iOS 中,操作队列不使用 Grand Central Dispatch 来执行操作。它们为非并发操作创建单独的线程,并从当前线程启动并发操作。
但我发现在iOS 4.2.1中,队列总是为并发或非并发操作创建线程。我认为队列根本不关心并发或非并发,因为 isConcurrent 中的断点永远不会被破坏。所以我认为参考文献是错误的......
As the NSOperationQueue
Class Reference said:
In iOS, operation queues do not use Grand Central Dispatch
to execute operations. They create separate threads for non-concurrent operations and launch concurrent operations from the current thread.
But I found in iOS 4.2.1,queue always create threads for concurrent or non-concurrent operations. And I think queue don't care concurrent or non-concurrent at all, because a breakpoint in isConcurrent never be broken. So I think the Reference was wrong...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您查看 NSOperation 的文档,您应该会看到有关 Mac 10.6(大致相当于 iOS 4.0)忽略 isConcurrent 的注释。
基本上,创建并发 NSOperation 的唯一原因是您要手动触发它。
If you look at the documentation for NSOperation, you should see a note about Mac 10.6 (which roughly corresponds to iOS 4.0) ignoring isConcurrent.
Basically, the only reason to create a concurrent NSOperation would be if you were going to fire it manually.
NSOperationQueue
确实使用了 GCD。来自文档:NSOperationQueue
does use GCD. From the documentation: