| 6 |
| 7 |
| 8 | namespace base { |
| 9 |
| 10 | PendingTask::PendingTask() = default; |
| 11 |
| 12 | PendingTask::PendingTask(const Location& posted_from, |
| 13 | OnceClosure task, |
| 14 | TimeTicks delayed_run_time, |
| 15 | Nestable nestable) |
| 16 | : task(std::move(task)), |
| 17 | posted_from(posted_from), |
| 18 | delayed_run_time(delayed_run_time), |
| 19 | nestable(nestable) {} |
| 20 |
| 21 | PendingTask::PendingTask(PendingTask&& other) = default; |
| 22 |
| 23 | PendingTask::~PendingTask() = default; |
| 24 |
| 25 | PendingTask& PendingTask::operator=(PendingTask&& other) = default; |
| 26 |
| 27 | bool PendingTask::operator<(const PendingTask& other) const { |
| 28 | // Since the top of a priority queue is defined as the "greatest" element, we |
| 29 | // need to invert the comparison here. We want the smaller time to be at the |
| 30 | // top of the heap. |
| 31 |
| 32 | if (delayed_run_time < other.delayed_run_time) |
| 33 | return false; |
| 34 |
| 35 | if (delayed_run_time > other.delayed_run_time) |
| 36 | return true; |
| 37 |
| 38 | // If the times happen to match, then we use the sequence number to decide. |
| 39 | // Compare the difference to support integer roll-over. |
| 40 | return (sequence_num - other.sequence_num) > 0; |
| 41 | } |
| 42 |
| 43 | } // namespace base |
| 44 |