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, fml::closure task, fml::TimePoint target_time); 18 19 DelayedTask(const DelayedTask& other); 20 21 ~DelayedTask(); 22 23 const fml::closure& GetTask() const; 24 25 fml::TimePoint GetTargetTime() const; 26 27 bool operator>(const DelayedTask& other) const; 28 29 private: 30 size_t order_; 31 fml::closure task_; 32 fml::TimePoint target_time_; 33 }; 34 35 using DelayedTaskQueue = std::priority_queue<DelayedTask, 36 std::deque<DelayedTask>, 37 std::greater<DelayedTask>>; 38 39 } // namespace fml 40 41 #endif // FLUTTER_FML_DELAYED_TASK_H_ 42