| 1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
|---|---|
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef FLUTTER_FML_DELAYED_TASK_H_ |
| 6 | #define FLUTTER_FML_DELAYED_TASK_H_ |
| 7 | |
| 8 | #include <queue> |
| 9 | |
| 10 | #include "flutter/fml/closure.h" |
| 11 | #include "flutter/fml/task_source_grade.h" |
| 12 | #include "flutter/fml/time/time_point.h" |
| 13 | |
| 14 | namespace fml { |
| 15 | |
| 16 | class DelayedTask { |
| 17 | public: |
| 18 | DelayedTask(size_t order, |
| 19 | const fml::closure& task, |
| 20 | fml::TimePoint target_time, |
| 21 | fml::TaskSourceGrade task_source_grade); |
| 22 | |
| 23 | DelayedTask(const DelayedTask& other); |
| 24 | |
| 25 | ~DelayedTask(); |
| 26 | |
| 27 | const fml::closure& GetTask() const; |
| 28 | |
| 29 | fml::TimePoint GetTargetTime() const; |
| 30 | |
| 31 | fml::TaskSourceGrade GetTaskSourceGrade() const; |
| 32 | |
| 33 | bool operator>(const DelayedTask& other) const; |
| 34 | |
| 35 | private: |
| 36 | size_t order_; |
| 37 | fml::closure task_; |
| 38 | fml::TimePoint target_time_; |
| 39 | fml::TaskSourceGrade task_source_grade_; |
| 40 | }; |
| 41 | |
| 42 | using DelayedTaskQueue = std::priority_queue<DelayedTask, |
| 43 | std::deque<DelayedTask>, |
| 44 | std::greater<DelayedTask>>; |
| 45 | |
| 46 | } // namespace fml |
| 47 | |
| 48 | #endif // FLUTTER_FML_DELAYED_TASK_H_ |
| 49 |
