blob: c31ab9af264745c19042267d52aa0646edd83cb9 [file] [log] [blame]
[email protected]dd1f9fe2011-11-15 23:36:301// 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
danakj0a448602015-03-10 00:31:165#ifndef BASE_PENDING_TASK_H_
6#define BASE_PENDING_TASK_H_
[email protected]dd1f9fe2011-11-15 23:36:307
8#include <queue>
9
[email protected]c360bae72011-11-18 06:08:0210#include "base/base_export.h"
[email protected]dd1f9fe2011-11-15 23:36:3011#include "base/callback.h"
12#include "base/location.h"
[email protected]8f9a3a52013-06-28 15:14:1813#include "base/time/time.h"
[email protected]dd1f9fe2011-11-15 23:36:3014#include "base/tracking_info.h"
15
16namespace base {
17
18// Contains data about a pending task. Stored in TaskQueue and DelayedTaskQueue
19// for use by classes that queue and execute tasks.
[email protected]c360bae72011-11-18 06:08:0220struct BASE_EXPORT PendingTask : public TrackingInfo {
[email protected]dd1f9fe2011-11-15 23:36:3021 PendingTask(const tracked_objects::Location& posted_from,
22 const Closure& task);
23 PendingTask(const tracked_objects::Location& posted_from,
24 const Closure& task,
25 TimeTicks delayed_run_time,
26 bool nestable);
vmpstr7c7877062016-02-18 22:12:2427 PendingTask(const PendingTask& other);
[email protected]dd1f9fe2011-11-15 23:36:3028 ~PendingTask();
29
30 // Used to support sorting.
31 bool operator<(const PendingTask& other) const;
32
33 // The task to run.
34 Closure task;
35
36 // The site this PendingTask was posted from.
37 tracked_objects::Location posted_from;
38
39 // Secondary sort key for run time.
40 int sequence_num;
41
42 // OK to dispatch from a nested loop.
43 bool nestable;
cpuee8907952014-08-28 23:25:3744
45 // Needs high resolution timers.
46 bool is_high_res;
[email protected]dd1f9fe2011-11-15 23:36:3047};
48
danakj5d792152016-06-15 20:47:4749using TaskQueue = std::queue<PendingTask>;
[email protected]dd1f9fe2011-11-15 23:36:3050
[email protected]262060ff2011-11-17 23:26:5351// PendingTasks are sorted by their |delayed_run_time| property.
danakj5d792152016-06-15 20:47:4752using DelayedTaskQueue = std::priority_queue<base::PendingTask>;
[email protected]262060ff2011-11-17 23:26:5353
[email protected]dd1f9fe2011-11-15 23:36:3054} // namespace base
55
danakj0a448602015-03-10 00:31:1656#endif // BASE_PENDING_TASK_H_