30 May 2012 02:01
Slight variation on "PostTaskAndReply Pattern for BlockingPool Tasks?"
Rachel Blum <groby <at> chromium.org>
2012-05-30 00:01:07 GMT
2012-05-30 00:01:07 GMT
So here's another question in a similar vein: (Yes, it's slightly different. Sorry for the hijack :)
We currently fire off a bunch of requests that we know to cause database/network traffic (and hence, to post tasks - but the tasks posted are not under our control. Hence, I don't think SequencedTaskRunner applies). They all have closures that get posted back onto our current thread when individual requests are done, and we're currently ref-counting the number of outstanding callbacks. For bonus points, callbacks might create new task/callback pairs. Once all of them are done, the last one fires off the "on completion" task.
That seems like it's something we have adressed somewhere, somehow. Or am I just hoping against hope, and we'll have to stick with manual refcounting?
(For code: chrome/browser/ui/intents/web_intent_picker_controller.cc, look for pending_async_count)
Rachel
-- On Tue, May 29, 2012 at 4:26 PM, Darin Fisher <darin <at> chromium.org> wrote:
... and you can fire off an additional PostTaskAndReply that will be guaranteed to run after all of the other tasks have run. This might be easier than maintaining a counter.
-Darin--On Tue, May 29, 2012 at 4:24 PM, William Chan (陈智昌) <willchan <at> chromium.org> wrote:Oh, I see now that you're using sequenced tasks. You can get a SequencedTaskRunner from the SequencedWorkerPool::GetSequencedTaskRunner(SequencedToken) member function. SequencedTaskRunner, as a derived class of TaskRunner, has a PostTaskAndReply() member function.On Tue, May 29, 2012 at 4:23 PM, William Chan (陈智昌) <willchan <at> chromium.org> wrote:The blocking pool is a derived class of TaskRunner which provides a PostTaskAndReply() member function. You can probably build on top of this by having the reply closures share the necessary state (a counter or whatever) and run another closure when all the reply closures have completed.On Tue, May 29, 2012 at 4:16 PM, Mike Rossetti <mrossetti <at> chromium.org> wrote:I've got some database update code that is using PostSequencedWorkerTask(...) calls for queuing up the various database updates.Is there a pattern for notifying the posting thread (i.e. the main thread) that kicked off all of these updates once all of them have completed? Something similar to PostTaskAndReply?What I'd like to do is to queue up all of these sequenced tasks and then post one final sequenced task that then does the reply call back to the main thread.All advice will be appreciated!Mike--
Chromium Developers mailing list: chromium-dev <at> chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
--
Chromium Developers mailing list: chromium-dev <at> chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
Chromium Developers mailing list: chromium-dev <at> chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
Chromium Developers mailing list: chromium-dev <at> chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
RSS Feed