mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Implement ftl::TaskRunner::PostTaskForTime function. (#3165)
This commit is contained in:
parent
0c212af9a8
commit
db12c5e621
2
DEPS
2
DEPS
@ -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;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user