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.
5 #ifndef BASE_PENDING_TASK_H_
6 #define BASE_PENDING_TASK_H_
10 #include "base/base_export.h"
11 #include "base/callback.h"
12 #include "base/location.h"
13 #include "base/time/time.h"
14 #include "base/tracking_info.h"
18 // Contains data about a pending task. Stored in TaskQueue and DelayedTaskQueue
19 // for use by classes that queue and execute tasks.
20 struct BASE_EXPORT PendingTask
: public TrackingInfo
{
21 PendingTask(const tracked_objects::Location
& posted_from
,
23 PendingTask(const tracked_objects::Location
& posted_from
,
25 TimeTicks delayed_run_time
,
29 // Used to support sorting.
30 bool operator<(const PendingTask
& other
) const;
35 // The site this PendingTask was posted from.
36 tracked_objects::Location posted_from
;
38 // Secondary sort key for run time.
41 // OK to dispatch from a nested loop.
44 // Needs high resolution timers.
48 // Wrapper around std::queue specialized for PendingTask which adds a Swap
50 class BASE_EXPORT TaskQueue
: public std::queue
<PendingTask
> {
52 void Swap(TaskQueue
* queue
);
55 // PendingTasks are sorted by their |delayed_run_time| property.
56 typedef std::priority_queue
<base::PendingTask
> DelayedTaskQueue
;
60 #endif // BASE_PENDING_TASK_H_