Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If the question is "Can serial queue perform tasks asynchronously?" then the answer is no. If you think that it can, you should make sure that all tasks are really performing on the same queue. You can add the following line in the block and compare the output:</p> <pre><code>dispatch_async(self.serialQueue, ^{ NSLog(@"current queue:%p current thread:%@",dispatch_get_current_queue(),[NSThread currentThread]); </code></pre> <p>Make sure that you write NSLog in the block that performs on your queue and not in the enumerateGroupsWithTypes:usingBlock:failureBlock: Also you can try to create your queue like this</p> <pre><code>dispatch_queue_create("label", DISPATCH_QUEUE_SERIAL); </code></pre> <p>but I don't think that will change anything</p> <p>EDIT: By the way, method</p> <pre><code>enumerateGroupsWithTypes:usingBlock:failureBlock: </code></pre> <p>is asynchronous, why do you call it on another queue?</p> <p>UPDATE 2: I can suggest something like this:</p> <pre><code>dispatch_async(queue, ^{ NSLog(@"queue"); pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER, *pmutex = &amp;mutex; pthread_mutex_lock(pmutex); ALAssetsLibraryGroupsEnumerationResultsBlock listGroupBlock = ^(ALAssetsGroup *group, BOOL *stop) { NSLog(@"block"); if (group) { [groups addObject:group]; } else { [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO]; dispatch_async(dispatch_get_current_queue(), ^{ pthread_mutex_unlock(pmutex); }); } NSLog(@"block end"); }; [assetsLibrary enumerateGroupsWithTypes:groupTypes usingBlock:listGroupBlock failureBlock:failureBlock]; pthread_mutex_lock(pmutex); pthread_mutex_unlock(pmutex); pthread_mutex_destroy(pmutex); NSLog(@"queue end"); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload