Dispatch, dispatcher

Source: Internet
Author: User

Dispatch, dispatcher

GCD provides and manages several FIFO queues (queues) and can submit tasks to these FIFO sequences in the form of blocks. GCD maintains a thread pool, and all tasks run in the thread pool.

Main queue provided by the system

After the system starts, a special queue is created, called the main queue ). Tasks in the main queue are sequentially executed in the main thread. (That is to say, the main thread does not necessarily have a main queue column)

Attempting to synchronously execute a work item on the main queue results in dead-lock.

Global concurrent dispatch queues

It is obtained through the specified quality of service (QoS.

Dispatch Semaphores

A dispatch semaphore is an efficient implementation of a traditional counting semaphore. Dispatch semaphores call down to the kernel only when the calling thread needs to be blocked. If the calling semaphore does not need to block, no kernel call is made.

Dispatch semaphore is more efficient than traditional semaphores.

Dispatch Barriers

A dispatch barrier allows you to create a synchronization point within a concurrent dispatch queue. When it encounters a barrier, a concurrent queue delays the execution of the barrier block (or any further blocks) until all blocks submitted before the barrier finish executing. At that point, the barrier block executes by itself. Upon completion, the queue resumes its normal execution behavior

A synchronization mechanism is provided, provided that the dispatch queue is parallel and not global concurrent dispatch queue.
The execution sequence is like this:
Previous block-> This block-> subsequent block

How to Use GCD (Grand Central Dispatch)

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.