哎呀,没有人鸟我。。
首先,gcd是开源,所以你可以去读libdispatch的源码。臆断万千不如源码在手
GCD是多核处理,有同步也有异步方法,可以开一个dispatchqueue处理数据,完了getmainqueue来刷新界面,可以用dispatchgroup来顺序执行多个任务,线程同步有barriar,延时可以用dispatchafter,单例创建可以用dispatchonce,定时器可以用dispatch_timer....总之GCD知识很多,多看看,取自己需要的。
话说GCD还真没仔细研究过他使用什么实现多核的。坐等大神答案。
GCD works by allowing specific tasks in a program that can be run in parallel to be queued up for execution and, depending on availability of processing resources, scheduling them to execute on any of the available processor cores[11][12] (referred to as "routing" by Apple).[13] GCD works by allowing specific tasks in a program that can be run in parallel to be queued up for execution and, depending on availability of processing resources, scheduling them to execute on any of the available processor cores[11][12] 应该是类似线程池的管理,不是单纯的队列。应该也是异步的
3楼 @crespoxiao 你说的大概就是如下的把:
// 后台执行:
dispatchasync(dispatchgetglobalqueue(0, 0), ^{ // something // 主线程执行: dispatchasync(dispatchgetmainqueue(), ^{ // something });
});
5楼 @zhangmeteor 多核肯定是多核的,但是到底是同步还是异步的,如上代码你觉得是异步的么?
7楼 @zhangmeteor 我也是那么觉得,但是我们loader说不是,他干了很多年,我就有点点点点点怀疑我是不是理解错了。这就来求证来了。