GCD and Nsoperationqueue differences

Source: Internet
Author: User

NSOpertaionQueueBuilding encapsulation with GCD is a high-level abstraction of GCD.
GCD only supports FIFO queues, while queues in Nsoperationqueue can be prioritized to perform order adjustments for different operations.
GCD does not support dependency settings between asynchronous operations. If an operation relies on data from another operation (the producer-consumer model is one of them), use Nsoperationqueue to perform the operation in the correct order. GCD does not have built-in dependency support.
Nsoperationqueue supports KVO, which means that we can observe the execution state of a task.

To understand the above differences, we can define the principles from the following perspectives
1. Performance
GCD is closer to the bottom, while Nsoperationqueue is more advanced abstraction, so GCD is the fastest in the pursuit of performance-underlying operations. This depends on using instruments for code performance analysis, if necessary

2. Transactional, sequential line, dependency between asynchronous operations. GCD needs to write more code to implement it, and Nsoperationqueue has built in these support

3. Nsoperationqueue is a better choice if the process of an asynchronous operation requires more interaction and UI rendering. In the underlying code, the tasks are less dependent on each other and require higher concurrency, and the GCD is more advantageous

GCD and Nsoperationqueue differences

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.