Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dispatch_queue_create multiple invocations with same label

I have a requirement to execute a small set of related tasks on a custom thread created for them. The tasks will be scheduled from different classes. I'm planning to use GCD's dispatch_queue_create to create the custom thread and schedule the task on it. Note that all the related tasks must execute only on that one thread in order.
So my question is if I call dispatch_queue_create("my_custom_thread_label", NULL) with the same label from many classes in my codebase, would it all eventually map to just one thread? Or do I need to create it in one place and get a reference to it whenever needed? Thanks.

like image 943
George Burdell Avatar asked Oct 27 '11 23:10

George Burdell


1 Answers

You need to create it in one place and pass the pointer around.

like image 130
jsd Avatar answered Oct 11 '22 10:10

jsd