Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium 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 PENDING_TASK_H_ | |
| 6 #define PENDING_TASK_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <queue> | |
| 10 | |
| 11 #include "base/callback.h" | |
| 12 #include "base/location.h" | |
| 13 #include "base/profiler/tracked_time.h" | |
| 14 #include "base/time.h" | |
| 15 #include "base/tracking_info.h" | |
| 16 | |
| 17 namespace tracked_objects { | |
| 18 class Births; | |
| 19 } | |
| 20 | |
| 21 namespace base { | |
| 22 | |
| 23 // Contains data about a pending task. Stored in TaskQueue and DelayedTaskQueue | |
| 24 // for use by classes that queue and execute tasks. | |
| 25 struct PendingTask : public base::TrackingInfo { | |
| 26 PendingTask(const tracked_objects::Location& posted_from, | |
| 27 const base::Closure& task); | |
| 28 PendingTask(const tracked_objects::Location& posted_from, | |
| 29 const base::Closure& task, | |
| 30 base::TimeTicks delayed_run_time, | |
| 31 bool nestable); | |
| 32 ~PendingTask(); | |
| 33 | |
| 34 // Used to support sorting. | |
| 35 bool operator<(const PendingTask& other) const; | |
| 36 | |
| 37 // The task to run. | |
| 38 base::Closure task; | |
| 39 | |
| 40 // The site this PendingTask was posted from. | |
| 41 tracked_objects::Location posted_from; | |
| 42 | |
| 43 // Secondary sort key for run time. | |
| 44 int sequence_num; | |
| 45 | |
| 46 // OK to dispatch from a nested loop. | |
| 47 bool nestable; | |
| 48 }; | |
| 49 | |
| 50 // Wrapper around std::queue specialized for PendingTask which adds a Swap | |
| 51 // helper method. | |
| 52 class TaskQueue : public std::queue<PendingTask> { | |
|
awong
2011/11/14 21:39:31
I don't think you can inherit from queue<>. The d
James Hawkins
2011/11/14 21:45:22
Caveat: This code is directly cut-pasted from Mess
| |
| 53 public: | |
| 54 void Swap(TaskQueue* queue); | |
| 55 }; | |
| 56 | |
| 57 typedef std::priority_queue<PendingTask> DelayedTaskQueue; | |
| 58 | |
| 59 } // namespace base | |
| 60 | |
| 61 #endif // PENDING_TASK_H_ | |
| OLD | NEW |