"Reading notes" Gcd-dispatch Queue

Source: Internet
Author: User

One, the implementation of the Dispatch queue:

1, used to manage the FIFO queue implemented by the C language layer of the appended block.

A lightweight signal for exclusive control implemented in the 2,atomic function.

3, some containers that are implemented by the C language layer for managing threads.

Second, the benefits of CGD.

No matter how hard programmers try to write code that manages threads, it is not possible to outperform the GCD implemented at the XNU kernel level in terms of performance.

Using GCD is better than using these generic multithreaded programming APIs like Pthreads and Nsthread. And, if you're using GCD, you don't have to write a similar source code that's recurring for the operation thread (this is called a fixed source snippet), and it's really a lot of benefit to be able to centralize the processing in the threads. We try to use GCD as much as possible or use APIs such as the Nsoperationqueue class GCD the cocoa framework.

Third, the GCD APIs used by programmers are all C-language functions included in the Libdispatch library. The Dispatch queue is implemented as a FIFO queue through structs and linked lists. FIFO Queue Management is a block that is appended by functions such as Dispatch_async.

Instead of joining the Fifi Queue directly, Block joins the dispatch continuation in the dispatch_continuation_t type struct and then joins the FIFO queue. The dispatch continuation is used to memorize the dispatch group and other information that the bloc belongs to, which is equivalent to the commonly used execution context.

Reference: "Objective-c advanced Programming iOS and OS X multithreading and memory Management"

  

"Reading notes" Gcd-dispatch Queue

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.