Implement ftl::TaskRunner::PostTaskForTime function. (flutter/engine#3165)
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user