GCD和外螺纹 [英] GCD and foreign thread

查看:85
本文介绍了GCD和外螺纹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以创建新的(或关联现有的)调度队列并将其绑定到特定线程?

Is there a way I can create a new (or associate an existing) dispatch queue and tie it to a specific thread?

我有一个AudioUnit回调proc在我无法控制的线程上运行,并且希望在正确执行回调之前,检查某个给定的队列是否有任何块供我在该AudioUnit线程中处理.

I have an AudioUnit callback proc running on a thread I do not control and would like, prior to executing the callback proper, check if some given queue has any block for me to process within that AudioUnit thread.

我可能可以使用OSAmtomicEnqueue和朋友,但是想知道GCD是否已经提供了某种转义"功能,允许我将特定线程绑定到特定队列?

I can probably use OSAmtomicEnqueue and friends, but was wondering whether GCD already offered some kind of "escape" allowing me to tie a specific thread to a specific queue?

推荐答案

根据Apple的文档,答案是否定的.

According to Apple'doc, the answer is no.

GCD提供和管理您的应用程序可以访问的FIFO队列 以块对象的形式提交任务.提交给的区块 分派队列在完全由线程管理的线程池上执行 系统.无法保证执行任务的线程 执行.

GCD provides and manages FIFO queues to which your application can submit tasks in the form of block objects. Blocks submitted to dispatch queues are executed on a pool of threads fully managed by the system. No guarantee is made as to the thread on which a task executes.

这篇关于GCD和外螺纹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆