From GCD Link : typedef struct dispatch_queue_s *dispatch_queue_t;
Maybe I bark the wrong tree, but my gut will tell me that a more idiomatic solution might be to use the dispatch_once function inside the class method to get a queue with which multiple instances of the class can send work (this is not C ++ but you get the main idea):
+ (dispatch_queue_t)sharedQueue { static dispatch_once_t pred; static dispatch_queue_t sharedDispatchQueue; dispatch_once(&pred, ^{ sharedDispatchQueue = dispatch_queue_create("theSharedQueue", NULL); }); return sharedDispatchQueue; }
dispatch_once ensures that queues are created only once during the entire execution time, so you can safely and cheaply call [YourClass sharedQueue] as often as you need, wherever you need to be.
However, my gut would also tell me that queuing between classes / objects smells a bit bad. If you just want the application queue to send different jobs, will the global queue be enough? If you want to do intensive work with large collections of objects, I would instinctively set up a separate queue for them. Maybe there is a more elegant way to do what you want?
source share