PostTaskAndReplyWithResult could be delay?

231 views
Skip to first unread message

18楼梦想改造家

unread,
Nov 22, 2023, 10:50:40 AM11/22/23
to scheduler-dev
Hey, everybody.

when I use function `|PostTask|`, if I want to make it delay, I could use PostDelayedTask to archive it.

But when I use `|PostTaskAndReplyWithResult|` , I don't found some function liked `|PostDelayedTaskAndReplyWithResult|`, Is there are a API like this to make it delayed?

Thx!

Alexander Timin

unread,
Nov 22, 2023, 1:25:22 PM11/22/23
to 18楼梦想改造家, scheduler-dev
PostTaskAndReplyWithResult is just a helper around binding two tasks and plumbing the task runner — you can achieve the same effect manually:

void RunAndReply(const scoped_refptr<TaskRunner> reply_task_runner, base::OnceClosure task, base::OnceClosure reply) {
  std::move(task).Run();
  reply_task_runner->PostTask(FROM_HERE, std::move(reply_task));
}

task_runner->PostDelayedTask(FROM_HERE, delay, base::BindOnce(
  &ReplyHelper, reply_task_runner, std::move(task) std::move(reply)));

--
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/a8d57345-b93a-4138-8e37-ce2a878141e2n%40chromium.org.
Reply all
Reply to author
Forward
0 new messages