In the code snippet below, I am trying to have a routine run concurrently with GCD. However, the queue runs the code serially. How would one force the queue to run concurrently? The WWDC 2017 VIDEO shows:
dispatch_apply( DISPATCH_APPLY_AUTO , count , ^(size_t i) { ...} );
but Xcode doesn't seem to recognize this syntax. Would there be a value for the flag parameter of dispatch_get_global_queue that would force concurrency.
code-block dispatch_queue_t aQueue = dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0); dispatch_apply( turnsMax , aQueue , ^( size_t t ) {
Rather than have dispatch_apply() run the loop I have replaced the above with repeated calls to dispatch_async() to avoid the problem. The following code works like a hose.
- (void)searchTreeBranches { int n; RBK_Turn turn; // load up the processor cores for ( n = 0 ; n < turnsMax; n++) { turn = turns[n]; dispatch_async( myDispatchQueue, ^( void ) { ••• }); } }