| 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 "flutter/fml/closure.h" |
| 9 | #include "flutter/fml/time/time_point.h" |
| 10 | |
| 11 | #include <queue> |
| 12 | |
| 13 | namespace fml { |
| 14 | |
| 15 | class DelayedTask { |
| 16 | public: |
| 17 | DelayedTask(size_t order, |
| 18 | const fml::closure& task, |
| 19 | fml::TimePoint target_time); |
| 20 | |
| 21 | DelayedTask(const DelayedTask& other); |
| 22 | |
| 23 | ~DelayedTask(); |
| 24 | |
| 25 | const fml::closure& GetTask() const; |
| 26 | |
| 27 | fml::TimePoint GetTargetTime() const; |
| 28 | |
| 29 | bool operator>(const DelayedTask& other) const; |
| 30 | |
| 31 | private: |
| 32 | size_t order_; |
| 33 | fml::closure task_; |
| 34 | fml::TimePoint target_time_; |
| 35 | }; |
| 36 | |
| 37 | using DelayedTaskQueue = std::priority_queue<DelayedTask, |
| 38 | std::deque<DelayedTask>, |
| 39 | std::greater<DelayedTask>>; |
| 40 | |
| 41 | } // namespace fml |
| 42 | |
| 43 | #endif // FLUTTER_FML_DELAYED_TASK_H_ |
| 44 | |