Does every NSThread automatically send a queue?

By default, is each thread associated with a send queue? I'm just wondering if I can use dispatch_semaphore in every context, or if I need to wrap it in an explicit dispatch call with a specific queue.

+6
source share
1 answer

It really doesn't work as your question suggests. By default, there is a main send queue associated with the main thread, and three global queues (high, default, and low priority, respectively) that are parallel.

Parallel queues manage their thread resources rather than being associated with any particular thread.

In fact, he says specifically on the manual page for dispatch_queue_create() :

"Queues are not tied to any particular thread of execution, and blocks transferred to independent queues can be executed simultaneously."

Regarding the use of send semaphores outside of send queues (another part of your question), the answer is yes, you can. Theyre implemented on top of Mach semaphores and should work everywhere. You can see the code here:

http://opensource.apple.com/source/libdispatch/libdispatch-84.5.5/src/semaphore.c

+7
source

Source: https://habr.com/ru/post/885496/


All Articles