Implement ftl::TaskRunner::PostTaskForTime function. (flutter/engine#3165)

This commit is contained in:
Jeff Brown
2016-10-21 13:09:54 -07:00
committed by GitHub
parent bb90af8f4a
commit 94cb74f076
3 changed files with 12 additions and 1 deletions

View File

@@ -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(

View File

@@ -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;