gpt4 book ai didi

ios - 什么是 dispatch_queue_create 中的队列属性

转载 作者:可可西里 更新时间:2023-11-01 06:24:09 32 4
gpt4 key购买 nike

在 Apple 的示例代码中,AVCam-iOS: Using AVFoundation to Capture Images and Movies ,我注意到以下一行:

// Communicate with the session and other session objects on this queue.
self.sessionQueue = dispatch_queue_create( "session queue", DISPATCH_QUEUE_SERIAL );

我想知道第二个参数是关于什么的,除了 DISPATCH_QUEUE_SERIAL 我们还有哪些其他选项?

令人困惑的是,在其他 Apple 文档中,它说第二个参数是保留的,应该设置为 NULL。似乎文档已过时,任何人都可以解释第二个参数应该是什么吗?

The dispatch_queue_create function takes two parameters: the queue name and a set of queue attributes. The queue attributes are reserved for future use and should be NULL. Concurrency Programming Guide

最佳答案

dispatch_queue_t dispatch_queue_create(const char *label, dispatch_queue_attr_t attr);

Queues are created with the dispatch_queue_create() function. Queues, like all dispatch objects, are reference counted and newly created queues have a reference count of one.

The optional label argument is used to describe the purpose of the queue and is useful during debugging and performance analysis. If a label is provided, it is copied. By convention, clients should pass a reverse DNS style label. For example:

my_queue = dispatch_queue_create("com.example.subsystem.taskXYZ", NULL);

The attr argument specifies the type of queue to create and must be either DISPATCH_QUEUE_SERIAL or DISPATCH_QUEUE_CONCURRENT.

来自 https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/dispatch_queue_create.3.html

关于ios - 什么是 dispatch_queue_create 中的队列属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35828520/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com