Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(606)

Side by Side Diff: base/pending_task.h

Issue 395913006: High resolution timer fix for Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: real fixes for review Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PENDING_TASK_H_ 5 #ifndef PENDING_TASK_H_
6 #define PENDING_TASK_H_ 6 #define PENDING_TASK_H_
7 7
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "base/tracking_info.h" 14 #include "base/tracking_info.h"
15 15
16 namespace base { 16 namespace base {
17 17
18 // Contains data about a pending task. Stored in TaskQueue and DelayedTaskQueue 18 // Contains data about a pending task. Stored in TaskQueue and DelayedTaskQueue
19 // for use by classes that queue and execute tasks. 19 // for use by classes that queue and execute tasks.
20 struct BASE_EXPORT PendingTask : public TrackingInfo { 20 struct BASE_EXPORT PendingTask : public TrackingInfo {
21 #if _MSC_VER >= 1700
22 PendingTask();
23 #endif
24 PendingTask(const tracked_objects::Location& posted_from, 21 PendingTask(const tracked_objects::Location& posted_from,
25 const Closure& task); 22 const Closure& task);
26 PendingTask(const tracked_objects::Location& posted_from, 23 PendingTask(const tracked_objects::Location& posted_from,
27 const Closure& task, 24 const Closure& task,
28 TimeTicks delayed_run_time, 25 TimeTicks delayed_run_time,
29 bool nestable); 26 bool nestable);
30 ~PendingTask(); 27 ~PendingTask();
31 28
32 // Used to support sorting. 29 // Used to support sorting.
33 bool operator<(const PendingTask& other) const; 30 bool operator<(const PendingTask& other) const;
34 31
35 // The task to run. 32 // The task to run.
36 Closure task; 33 Closure task;
37 34
38 // The site this PendingTask was posted from. 35 // The site this PendingTask was posted from.
39 tracked_objects::Location posted_from; 36 tracked_objects::Location posted_from;
40 37
41 // Secondary sort key for run time. 38 // Secondary sort key for run time.
42 int sequence_num; 39 int sequence_num;
43 40
44 // OK to dispatch from a nested loop. 41 // OK to dispatch from a nested loop.
45 bool nestable; 42 bool nestable;
43
44 // Needs high resolution timers.
45 bool is_high_res;
46 }; 46 };
47 47
48 // Wrapper around std::queue specialized for PendingTask which adds a Swap 48 // Wrapper around std::queue specialized for PendingTask which adds a Swap
49 // helper method. 49 // helper method.
50 class BASE_EXPORT TaskQueue : public std::queue<PendingTask> { 50 class BASE_EXPORT TaskQueue : public std::queue<PendingTask> {
51 public: 51 public:
52 void Swap(TaskQueue* queue); 52 void Swap(TaskQueue* queue);
53 }; 53 };
54 54
55 // PendingTasks are sorted by their |delayed_run_time| property. 55 // PendingTasks are sorted by their |delayed_run_time| property.
56 typedef std::priority_queue<base::PendingTask> DelayedTaskQueue; 56 typedef std::priority_queue<base::PendingTask> DelayedTaskQueue;
57 57
58 } // namespace base 58 } // namespace base
59 59
60 #endif // PENDING_TASK_H_ 60 #endif // PENDING_TASK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698