There is no public API to request the number of tasks in the GCD queue. You can either create something yourself, or use it NSOperationQueue. If you want to create something, you can wrap dispatch_a/syncit up to increase the counter, and then set another block with each operation, which decreases the counter, for example:
int64_t numTasks = 0
void counted_dispatch_async(dispatch_queue_t queue, dispatch_block_t block)
{
OSAtomicIncrement64(&numTasks);
dispatch_async(queue, ^{
block();
OSAtomicDecrement64(&numTasks);
});
}
NSOperationQueue. , . : " , ".