About dispatch_queue_t的线程调度

本文介绍了dispatch_queue_t的概念及其工作原理,包括系统如何通过线程池处理dispatchqueues中的blocks,以及不同queues之间的高度异步交互。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

dispatch_queue_t
A dispatch queue is a lightweight object to which your application submits blocks for subsequent execution.

typedef struct dispatch_queue_s *dispatch_queue_t;
Discussion
A dispatch queue invokes blocks submitted to it serially in FIFO order. A serial queue invokes only one block at a time, but independent queues may each invoke their blocks concurrently with respect to each other.

The global concurrent queues invoke blocks in FIFO order but do not wait for their completion, allowing multiple blocks to be invoked concurrently.

The system manages a pool of threads that process dispatch queues and invoke blocks submitted to them. Conceptually, a dispatch queue may have its own thread of execution, and interaction between queues is highly asynchronous.

Dispatch queues are reference counted via calls to dispatch_retain and dispatch_release. Pending blocks submitted to a queue also hold a reference to the queue until they have finished. Once all references to a queue have been released, the queue will be deallocated by the system.

Availability
Available in iOS 4.0 and later.
Declared In
dispatch/queue.h


关于dispatch_queue_t的系统线程处理,系统维护了一个线程池,dispatch queues中的blocks会提交给线程池中的线程进行处理。一个dispatch queue可能拥有自己的线程执行任务,不同queues之间是高度异步的。

 

转载于:https://www.cnblogs.com/weisteve/archive/2013/05/01/3053298.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值