The description of this method on https://developer.apple.com/library/mac/documentation/Cocoa/Reference/NSOperationQueue_class/Reference/Reference.html#//apple_ref/occ/instm/NSOperationQueue/waitUntilAllOperationsAreFinished says:
When called, this method blocks the current thread and waits for the receiver’s current and queued operations to finish executing. While the current thread is blocked, the receiver continues to launch already queued operations and monitor those that are executing. During this time, the current thread cannot add operations to the queue, but other threads may. Once all of the pending operations are finished, this method returns.
I wonder what is the code behind waitUntilAllOperationsAreFinished that allows such behavior (blocks current thread, receiver continues...)? I am interested in writing a code producing similar behavior, so I will be thankful for any equivalent (yeah, Apple is black boxed for me) code behaving in a similar way.
More specifically: how NSOperationQueue does its thread blocking, at the same time allowing receiver to work on its stuff (my guess: dispatch semaphores while running currentRunLoop)?
Thanks!