Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <a href="http://developer.apple.com/library/ios/#documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html#//apple_ref/doc/uid/TP40008091-CH102-SW6" rel="nofollow">docs</a> provide the following answer:</p> <blockquote> <p>Serial queues are useful when you want your tasks to execute in a specific order. A serial queue executes only one task at a time and always pulls tasks from the head of the queue. You might use a serial queue instead of a lock to protect a shared resource or mutable data structure. Unlike a lock, a serial queue ensures that tasks are executed in a predictable order.</p> <p>...</p> <pre><code> dispatch_queue_t queue; queue = dispatch_queue_create("com.example.MyQueue", NULL); </code></pre> </blockquote> <p>So you're doing the right thing in principle. You're probably spinning off each block on a separate thread. That won't work, because each separate serial queue will run concurrently. Just submit all the work onto the same queue and you should be golden.</p> <p><strong>Edit I:</strong></p> <p>Well, I'm stumped as far as GCD is concerned. Maybe you can try the <code>NSOperation</code> family of classes? You can create NSBlockOperation and add it to an NSOperationQueue, as described in <a href="http://developer.apple.com/library/ios/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationObjects/OperationObjects.html#//apple_ref/doc/uid/TP40008091-CH101-SW2" rel="nofollow">this doc</a>. If you create a second (or third etc.) <code>NSBlockOperation</code>, you can do <code>[anotherBlock addDependency:[yourNSOperationQueue.operations lastObject]]</code> and that should make <code>anotherBlock</code> wait for the operation you last added to <code>yourNSOperationQueue</code>.</p> <p>For reference (<a href="http://developer.apple.com/library/ios/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationObjects/OperationObjects.html#//apple_ref/doc/uid/TP40008091-CH101-SW17" rel="nofollow">source</a>):</p> <blockquote> <p>To establish dependencies between two operation objects, you use the addDependency: method of NSOperation. This method creates a one-way dependency from the current operation object to the target operation you specify as a parameter. This dependency means that the current object cannot begin executing until the target object finishes executing.</p> </blockquote>
    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. VO
      singulars
      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