task_runner.h 995 字节
Newer Older
1 2 3 4 5 6 7
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_FML_TASK_RUNNER_H_
#define FLUTTER_FML_TASK_RUNNER_H_

8 9 10
#include "lib/fxl/macros.h"
#include "lib/fxl/memory/ref_counted.h"
#include "lib/fxl/tasks/task_runner.h"
11 12 13 14 15

namespace fml {

class MessageLoopImpl;

16
class TaskRunner : public fxl::TaskRunner {
17
 public:
18
  void PostTask(fxl::Closure task) override;
19

20
  void PostTaskForTime(fxl::Closure task, fxl::TimePoint target_time) override;
21

22
  void PostDelayedTask(fxl::Closure task, fxl::TimeDelta delay) override;
23 24 25 26

  bool RunsTasksOnCurrentThread() override;

 private:
27
  fxl::RefPtr<MessageLoopImpl> loop_;
28

29
  TaskRunner(fxl::RefPtr<MessageLoopImpl> loop);
30

31
  ~TaskRunner();
32 33 34

  FRIEND_MAKE_REF_COUNTED(TaskRunner);
  FRIEND_REF_COUNTED_THREAD_SAFE(TaskRunner);
35
  FXL_DISALLOW_COPY_AND_ASSIGN(TaskRunner);
36 37 38 39 40
};

}  // namespace fml

#endif  // FLUTTER_FML_TASK_RUNNER_H_