Dispatch Queues thread Pool

Source: Internet
Author: User

Dispatch Queues

Dispatch queues is a c-based mechanism for executing custom tasks. A dispatch queue executes tasks either serially or concurrently but always in a first-in, first-out order. (In other words, a dispatch queue always dequeues and starts tasks in the same order in which they were added to the queue .) A serial dispatch queue runs only one task at a time, waiting until this task is complete before dequeuing and starting a New one. By contrast, a concurrent dispatch queue starts as many tasks as it can without waiting for already started tasks to Finis H.

Dispatch queues has other benefits:

    • They provide a straightforward and simple programming interface.

    • They offer automatic and holistic thread pool management.

    • They provide the speed of tuned assembly.

    • They is much more memory efficient (because thread stacks does not linger in application memory).

    • They does not trap to the kernel under load.

    • The asynchronous dispatching of tasks to a dispatch queue cannot deadlock the queue.

    • They scale gracefully under contention.

    • Serial dispatch queues offer a more efficient alternative to locks and other synchronization primitives.

The tasks you submit to a dispatch queue must be encapsulated inside either a function or ablock object. block objects are a C language feature introduced in OS X v10.6 and IOS 4. 0 that is similar to function pointers conceptually, but has some additional benefits. Instead of defining blocks in their own lexical scope, you typically define blocks inside another function or method so th At they can access other variables from that function or method. Blocks can also be moved out of their original scope and copied onto the heap, which was what happens when you submit them to a dispatch queue. All of these semantics make it possible to implement very dynamic tasks with relatively little code. 

Dispatch queues is part of the Grand Central Dispatch Technology and is part of the C runtime. For more information about using the dispatch queues in your applications, see dispatch queues. For more information about blocks and their benefits, see blocks programming Topics.

https://developer.apple.com/library/content/documentation/General/Conceptual/ConcurrencyProgrammingGuide/ Concurrencyandapplicationdesign/concurrencyandapplicationdesign.html#//apple_ref/doc/uid/tp40008091-ch100-sw2

Dispatch Queues thread Pool

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.