I have two queues which both of them are serial with different identifier. In my code, I will dispatch a queue1 first and then inside the queue I will dispatch another queue.
Sample Code:
var queue1 = dispatch_queue_create ("com.sample.Queue1", DISPATCH_QUEUE_SERIAL)
var queue2 = dispatch_queue_create ("com.sample.Queue2", DISPATCH_QUEUE_SERIAL)
func function1(){
dispatch_sync(self.queue1, { //queue1
//LineA
dispatch_sync(self.queue2,{ //queue2
//LineB
//Some function need network communication
})
})
}
I will keep execute function1, so all the code inside function1 will queue up and run once at a time. (No concurrency)
But, if I run another queue inside queue1, LineA will call before queue2 finish all the code.
Question:
- I would like to know how to lock queue1 before queue2 finish the code. I would like to wait until queue2 finish the code before run a new queue1.
- Are there any concepts I have misunderstood?
Sorry for my english and I am new to multi-thread programming.