How can i handle REST requests from UI while background operation exists?

35 views
Skip to first unread message

Ariel .b

unread,
Dec 8, 2014, 12:00:30 PM12/8/14
to res...@googlegroups.com
Hello, i have a problem which i'm not sure how to solve.

i have an application, that uses the RESTKit and performs REST requests upon clicking some buttons.
until the REST request finishes, i show a "loading" image and then display the content.

the problem is, that every 10 minutes, i start a huge background operation which performs REST calls (that might take time).
while this is done, the calls from the UI are taking forever until they are finally handled from the operation queue.

i've tried tweaking the RESTKit and add set UI requests priority to NSOperationQueuePriorityVeryHigh and the quality to NSQualityOfServiceUserInitiated.

the background REST requests are VeryLow / Background quality.
the operation queue max limit is -1, which means, that it's decided by the operation system as i understand.

after doing that, i see that the request from the UI still takes long time. i've counted the number of background requests handled before and after this UI requests enter and it's several dozens.
i've changed the queue max limit to 1, and saw that indeed the UI operation starts right after the previous background operation starts. so the priority works well.

i've changed the max to 20, and it seemed better.

the problem is, that there might be 20 or more operations which are very heavy (1 minute+) and that means, that if i'll have those operations, the UI operation will not run until one of the long background operations end. which is a major problem.

i tried creating 2 separate RKObjectManager, and made the background process use the 2nd one. but it made things worst somehow.. 
i tried even creating 2 seperate AFHTTPClient. didn't work.


what am i missing?

Thanks!
Ariel
Reply all
Reply to author
Forward
0 new messages