multithreading - Attempting to run two processes simultaneously in GCD - iOS -


I am trying to load two set data in the background via GCD in the background simultaneously. At present, I created two specific concurrent queues, in which I run every work. However, the delay in completion of the first queue and the second line (which runs equally intensive tasks) is very large (so I think they are not running together) are you there any suggestions on how to fix this? ? I am not able to fully understand the way to reach it. ! Thanks

  dispatch_queue_t myQueue = dispatch_queue_create ("com.a.identifier", DISPATCH_QUEUE_CONCURRENT); Sender_qi_t myQueue2 = dispatch_queue_create ("com.a.identifier2", DISPATCH_QUEUE_CONCURRENT); Dispatch_async (myQueue, ^ {[self fetchDataWithDataFromUrl: [NSURL URLWithString: linkOne]]; dispatch_async (dispatch_get_main_queue (), ^ {[self.tableView reloadData];});}); Dispatch_async (myQueue2, ^ {[self fetchDataWithDataFromUrl2: [NSURL URLWithString: linkTwo]]; dispatch_async (dispatch_get_main_queue (), ^ {[self.tableView reloadData];});});  

They are running very likely they can not run in parallel It makes some promises about parallelism, it is true for many libraries (and usually a more important feature).

How many corpses do you have? If you have only one core, then it is not surprising that the second job is waiting to be completed first. If you have two cores, but there are so many things in the main line, then it is likely to get priority before one of your blocks. You should use tools to detect GCD tools so that things are being set up ( printf is also a powerful tool here). Remember, for the reference switching cost to get the best throughput at the core, you want to run a thing on that thing until the thing is done, then run the next thing. To complete them simultaneously, switching back and backward should be done gradually. There is no reason to swap the block to run the same priority block of bias through most system bias.

Do you know that both jobs get their data at the same time? If you are pulling from the network, it is very possible that you are able to pipeline over a connection that is serialing your network traffic faster or faster than one another. When you get the data you should log in you should block it when your block actually starts (put printf () at the top of the block.)

if You need to wait for the second time to complete the first job before updating the UI, so you should keep both jobs in one so that reloadData is waiting for them.

What you really need to dig and what is going on when needed. Such symptoms can sometimes mean that you are updating your UI somewhere else on the background thread. This can be delayed by getting a correct update (possibly doing nothing with this code) by using the printf () statements and tools to make sure that you know exactly what It is important to make the happen.

If you can break your work in small pieces and lay them out, it is more important than pacing throughput (which you are suggesting).

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -