ios queue及GCD理解的文章
来源:互联网 发布:apache2 php 编辑:程序博客网 时间:2024/06/08 08:12
(1)关于queue
The best way to conceptualize queues is to first realize that at the very low-level, there are only two types of queues: serial and concurrent.
Serial queues are monogamous, but uncommitted. If you give a bunch of tasks to each serial queue, it will run them one at a time, using only one thread at a time. The uncommitted aspect is that serials queues may switch to a different thread between tasks. Serial queues always wait for a task to finish before going to the next one. Thus tasks are completed in FIFO order. You can make as many serial queues as you need.
The main queue is a special serial queue. Unlike other serial queues, which are uncommitted, in that they are "dating" many threads but only one at time, the main queue is "married" to the main thread and all tasks are performed on it. The main queue behaves nicely with the main thread's runloop so that small operations don't block the UI and other important bits. Like all serial queues, tasks are completed in FIFO order.
If serial queues are monogamous, concurrent queues are promiscuous. They will submit tasks to any available thread or even make new threads depending on system load. They may perform multiple tasks simultaneously on different threads. It's important that tasks submitted to the global queue are thread-safe and minimize side-effects. Tasks are submitted for execution in FIFO order, but order of completion is not guaranteed.
Bringing it back, all global queues are concurrent and all user queues are serial.
If your goal is to download images, you probably want a serial (user) queue. Downloading images is more of a bandwidth thing. You usually only want to do a one (or a few) at a time.
(2)GCD
https://www.raywenderlich.com/60749/grand-central-dispatch-in-depth-part-1
- ios queue及GCD理解的文章
- IOS GCD queue group
- IOS- 对GCD的理解
- iOS gcd的基本理解
- IOS 对GCD 的理解。
- iOS开发:GCD的理解
- 【读书笔记】iOS-GCD-Dispatch Queue
- ios中关于GCD的理解
- iOS GCD 理解
- iOS系统GCD学习(2):Dispatch Queue
- iOS系统GCD学习(2):Dispatch Queue
- ios多线程之GCD dispatch queue
- iOS GCD介绍: 基本概念和Dispatch Queue
- IOS GCD学习和理解
- iOS GCD使用_理解
- iOS开发中GCD在多线程方面的理解
- iOS多线程GCD NSThread的使用和理解
- iOS 之GCD串行和并发队列的理解
- 用Android Studio打Jar包
- Linux系统下安装rz/sz命令及使用说明
- redhat压缩,解压,打包
- Html-颜色表
- JD-GUI在Ubuntu 14.04 64位系统依赖包失败的问题
- ios queue及GCD理解的文章
- 数字证书
- 【HDU 1208】Pascal's Travels(动态规划DP)
- 图像特征检测描述(一):SIFT、SURF、ORB、HOG、LBP特征的原理概述及OpenCV代码实现
- 栈的效率为什么比堆高?
- find ./ -name *.bak | xargs rm -rf 之
- Qt之线程基础
- 习题28 布尔表达式练习
- Android 蓝牙开发1