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)