dispatch
GCD提供了并管理着若干FIFO队列(queues),可以通过block的形式向这些FIFO序列提交任务。GCD同时维护着一个线程池,所有的任务在线程池的线程运行。
系统提供的队列
main queue
系统在启动后会创建一个特殊的队列,叫做主队列(main queue)。主队列中的任务在主线程中顺序执行。(也就是说主线程上的不一定是主队列)
Attempting to synchronously execute a work item on the main queue results in dead-lock.
global concurrent dispatch queues
通过指定的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比传统的信号量更有效率。
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
提供了一种同步机制,前提是dispatch queue是并行的,且不是global concurrent dispatch queue。
执行顺序会是这样子:
之前的block->这个block->之后的block
- GCD:嵌套dispatch_async时__block对象的一个内存陷阱
- Grand Central Dispatch(GCD)编程基础
- GCD教程(三):Dispatch Sources
- GCD 学习(八)dispatch_semaphore
- Event::dispatchEvent
- iOS多线程的初步研究(十)-- dispatch同步
- dispatch队列
- 细说Android事件传递机制(dispatchTouchEvent、onInterceptTouchEvent、onTouchEvent)
- UnityPlayerActivity报NativeActivity "Failed to receive dispatch singal. status = -11"
- iOS 倒计时方法——dispatch
- dispatch_set_target_queue一些理解
- 用IShellDispatch 接口 获得文件的摘要信息
- Grand Central Dispatch(GCD)介绍和使用
- IOS异步获取数据并刷新界面dispatch_async的使用方法
- spring mvc 配置DispatchServlet 的<url-pattern>/</url-pattern>的写法
- Android中的dispatchTouchEvent()、onInterceptTouchEvent()和onTouchEvent()
- Android中的dispatchTouchEvent()、onInterceptTouchEvent()和onTouchEvent()
- dispatch_async 和 dispatch_sync 的区别
- iOS开发之GCD(7)API dispatch_barrier_async
- ontouch、dispatchtouchevent、interceptouchevent-相关事件