I have two API calls as follows :
-(void) doTask1{
dispatch_async(queueSerial, ^{ //B1
[fileObj setFileInfo:file];
});
}
-(void) doTask2{
dispatch_async(queueSerial, ^{ //B2
[fileObj getFileInfo:fileName completion:^(NSError *error) {
dispatch_async(queueSerial2, ^{
//completion work C1
});
}]
});
}
Now, my question is, from what I already understand by reading about GCD, if a process calls doTask1
and immediately after calls doTask2
, it will result in both of them being queued and B1
ahead B2
.
However, does is ensure that B1
is fully executed before B2
starts executing? Because the file updated by B1
is used by B2
.
If B2
starts to execute before B1
is fully finished, it might result in some issues.
Or is it better to do
-(void) doTask1{
dispatch_sync(queueSerial, ^{B1});
}
-(void) doTask2{
dispatch_sync(queueSerial, ^{B2});
}