Add SequencedTaskRunner::PostTaskAndReplyWithResult()?

53 views
Skip to first unread message

Gabriel Charette

unread,
Jan 28, 2020, 7:29:30 PM1/28/20
to scheduler-dev, Francois Pierre Doray, Darin Fisher, Dana Jansens, Albert Wong
Hello folks,

as I'm migrating to task APIs v3. I realize that we now have base::ThreadPool::PostTaskAndReplyWithResult() but not base::SequencedTaskRunner::PostTaskAndReplyWithResult().

This makes the migration from base::PostTaskAndReplyWithResult(FROM_HERE, {BrowserThread::IO}, ...) weird as it can't just become content::GetIOThreadTaskRunner({})->PostTaskAndReplyWithResult() like all the other Post(Delayed)?Task(AndReply)? variants will.

I don't see a good reason for PostTaskAndReplyWithResult() to be a separate helper (on task_runner_util.h) anymore.

Thoughts?

See the thread_pool.h migration for an equivalence.

Cheers,
Gab

Darin Fisher

unread,
Jan 28, 2020, 7:30:52 PM1/28/20
to Gabriel Charette, scheduler-dev, Francois Pierre Doray, Dana Jansens, Albert Wong
+1

Darin Fisher

unread,
Jan 28, 2020, 7:32:31 PM1/28/20
to Gabriel Charette, scheduler-dev, Francois Pierre Doray, Dana Jansens, Albert Wong
Actually, shouldn't it be added to TaskRunner rather than SequencedTaskRunner?

-Darin

Gabriel Charette

unread,
Jan 28, 2020, 8:35:51 PM1/28/20
to Darin Fisher, Gabriel Charette, scheduler-dev, Francois Pierre Doray, Dana Jansens, Albert Wong
On Tue, Jan 28, 2020 at 7:32 PM Darin Fisher <da...@chromium.org> wrote:
Actually, shouldn't it be added to TaskRunner rather than SequencedTaskRunner?

Ah, yes indeed :)
 
--
You received this message because you are subscribed to the Google Groups "scheduler-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scheduler-de...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/scheduler-dev/CAP0-QpuoXRKTOPvrZgZrbzNimaM18AY%3DSvqH46ZjcsA5Km8bOA%40mail.gmail.com.

François Doray

unread,
Jan 28, 2020, 8:44:33 PM1/28/20
to Gabriel Charette, Darin Fisher, scheduler-dev, Dana Jansens, Albert Wong
+1 to adding on TaskRunner

Gabriel Charette

unread,
Jan 28, 2020, 8:59:15 PM1/28/20
to François Doray, Gabriel Charette, Darin Fisher, scheduler-dev, Dana Jansens, Albert Wong

Alexander Timin

unread,
Jan 29, 2020, 12:02:30 PM1/29/20
to Gabriel Charette, platform-architecture-dev, Kentaro Hara, François Doray, Darin Fisher, scheduler-dev, Dana Jansens, Albert Wong

+Kentaro Hara +platform-architecture-dev 

I think that from the Blink perspective we might want this to be a static function, which can be banned in blink.
The main reason is that we want to enforce a dedicated callback type for cross-thread task posting (WTF::CrossThreadOnceClosure) to be used, which guarantees that on-heap objects are correctly passed across threads (see blink::PostCrossThreadTask).



François Doray

unread,
Jan 29, 2020, 12:19:28 PM1/29/20
to Alexander Timin, Gabriel Charette, platform-architecture-dev, Kentaro Hara, Darin Fisher, scheduler-dev, Dana Jansens, Albert Wong
Would there be a reason to ban TaskRunner::PostTaskAndReplyWithResult but not TaskRunner::PostTask? Both methods can post a task to another thread.

Gabriel Charette

unread,
Jan 29, 2020, 1:51:07 PM1/29/20
to François Doray, Alexander Timin, Gabriel Charette, platform-architecture-dev, Kentaro Hara, Darin Fisher, scheduler-dev, Dana Jansens, Albert Wong
On Wed, Jan 29, 2020 at 12:19 PM François Doray <fdo...@chromium.org> wrote:
Would there be a reason to ban TaskRunner::PostTaskAndReplyWithResult but not TaskRunner::PostTask? Both methods can post a task to another thread.

I think altimin is referring to Blink's worker_pool:: API ? If you have a TaskRunner* you can already use its PostTaskAndReply so don't see why PostTaskAndReplyWithResult would be a problem.

Darin Fisher

unread,
Jan 29, 2020, 2:05:07 PM1/29/20
to Gabriel Charette, François Doray, Alexander Timin, platform-architecture-dev, Kentaro Hara, scheduler-dev, Dana Jansens, Albert Wong


On Wed, Jan 29, 2020, 10:51 AM Gabriel Charette <g...@chromium.org> wrote:


On Wed, Jan 29, 2020 at 12:19 PM François Doray <fdo...@chromium.org> wrote:
Would there be a reason to ban TaskRunner::PostTaskAndReplyWithResult but not TaskRunner::PostTask? Both methods can post a task to another thread.

I think altimin is referring to Blink's worker_pool:: API ? If you have a TaskRunner* you can already use its PostTaskAndReply so don't see why PostTaskAndReplyWithResult would be a problem.
 

+1

Alexander Timin

unread,
Jan 29, 2020, 5:11:48 PM1/29/20
to Darin Fisher, Gabriel Charette, François Doray, platform-architecture-dev, Kentaro Hara, scheduler-dev, Dana Jansens, Albert Wong
Ah, sorry for misleading — managed to confuse a lot of things here. Please disregard my comment above :(

+1 to the proposal SequencedTaskRunner::PostTaskAndReplyWithResult.

Also, TIL that we have a method on TaskRunner, thought that we have only a static function.

You received this message because you are subscribed to the Google Groups "platform-architecture-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to platform-architect...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/platform-architecture-dev/CAP0-QpstxPikFtNyCM0iStcxO1nfnszOSS9YGYhjJDHA-hY4Lw%40mail.gmail.com.

Kentaro Hara

unread,
Jan 29, 2020, 5:48:15 PM1/29/20
to Alexander Timin, Darin Fisher, Gabriel Charette, François Doray, platform-architecture-dev, scheduler-dev, Dana Jansens, Albert Wong
+1

--
Kentaro Hara, Tokyo, Japan

Albert J. Wong (王重傑)

unread,
Jan 29, 2020, 7:21:09 PM1/29/20
to Kentaro Hara, Alexander Timin, Darin Fisher, Gabriel Charette, François Doray, platform-architecture-dev, scheduler-dev, Dana Jansens
+1 too
Reply all
Reply to author
Forward
0 new messages