提交 db12c5e6 编写于 作者: J Jeff Brown 提交者: GitHub

Implement ftl::TaskRunner::PostTaskForTime function. (#3165)

上级 0c212af9
......@@ -54,7 +54,7 @@ deps = {
# and not have to specific specific hashes.
'src/lib/ftl':
Var('fuchsia_git') + '/ftl' + '@' + '5e9935c7205c119ce05098dc1d9c8eaac0595ba4',
Var('fuchsia_git') + '/ftl' + '@' + 'e8d8bf108418d5de96971ecd04b7cc0a58d8a568',
'src/lib/tonic':
Var('fuchsia_git') + '/tonic' + '@' + 'e1d221b924cb2a604363a8a9dd393d319becc0e8',
......
......@@ -30,6 +30,16 @@ void TaskRunnerAdaptor::PostTask(ftl::Closure task) {
runner_->PostTask(FROM_HERE, base::Bind(RunClosure, task));
}
void TaskRunnerAdaptor::PostTaskForTime(ftl::Closure task,
ftl::TimePoint target_time) {
ftl::TimePoint now = ftl::TimePoint::Now();
runner_->PostDelayedTask(FROM_HERE, base::Bind(RunClosure, task),
target_time <= now
? base::TimeDelta()
: base::TimeDelta::FromMicroseconds(
(target_time - now).ToMicroseconds()));
}
void TaskRunnerAdaptor::PostDelayedTask(ftl::Closure task,
ftl::TimeDelta delay) {
runner_->PostDelayedTask(
......
......@@ -19,6 +19,7 @@ class TaskRunnerAdaptor : public ftl::TaskRunner {
explicit TaskRunnerAdaptor(scoped_refptr<base::TaskRunner> runner);
void PostTask(ftl::Closure task) override;
void PostTaskForTime(ftl::Closure task, ftl::TimePoint target_time) override;
void PostDelayedTask(ftl::Closure task, ftl::TimeDelta delay) override;
bool RunsTasksOnCurrentThread() override;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册