ibireme / YYAsyncLayer

iOS utility classes for asynchronous rendering and display.
MIT License
682 stars 119 forks source link

NSOperationQueue 和 NSOperation 方式 #17

Open Beyond-Chao opened 6 years ago

Beyond-Chao commented 6 years ago

YY 大神你好,请教一个问题:

你用多个串行队列来实现并发、控制线程数量,避免GCD在并行队列上执行耗时任务时开辟过多线程、消耗系统资源。如果通过NSOperationQueue 和 NSOperation的方式,控制maxConcurrentOperationCount 为YYAsyncLayerGetDisplayQueue中的queueCount,能够实现同样的效果嘛?

Tangdixi commented 6 years ago

I prefer NSOperationQueue ~

xll503721 commented 5 years ago

NSOperation的实现其实也是CGD了,所以一般情况下NS一层怎么都会有性能损失的,NSOperation感觉比较适合用在你要管理线程状态的时候,比如NSOperation的start,ready等的状态,可以看SW和YYImageWeb,大量用到NSOperation,主要原因是如果你要对并行并行队列做状态控制的话,比较麻烦,所以不得不用NSOperation,但假如你只想控制线程数量,何必直接用CGD串行队列呢?