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

Unified Diff: components/scheduler/child/task_queue_impl.h

Issue 1259583006: Reland: Explicitly track the scheduler task enqueueing order in a new field (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/scheduler/child/task_queue_impl.h
diff --git a/components/scheduler/child/task_queue_impl.h b/components/scheduler/child/task_queue_impl.h
index 1e05e5ab0069ef0dbc0198ca11b332e5ec8beee7..53593953c08ce94d47a73f7471204dfbd941f349 100644
--- a/components/scheduler/child/task_queue_impl.h
+++ b/components/scheduler/child/task_queue_impl.h
@@ -20,6 +20,17 @@ class TaskQueueManager;
namespace internal {
+struct SchedulerTask : public base::PendingTask {
Sami 2015/08/05 11:27:34 Sorry to go all bikeshed on this but I think TQM i
alex clarke (OOO till 29th) 2015/08/05 14:32:43 Done.
+ SchedulerTask();
+ SchedulerTask(const tracked_objects::Location& posted_from,
+ const base::Closure& task,
+ bool nestable);
+
+ // Similar to sequence number, but the task age is not defined for delayed
+ // tasks until enqueued on the |incomming_queue_|.
Sami 2015/08/05 11:27:34 typo: incoming
alex clarke (OOO till 29th) 2015/08/05 14:32:43 Done.
+ int age;
+};
+
class SCHEDULER_EXPORT TaskQueueImpl final : public TaskQueue {
public:
TaskQueueImpl(TaskQueueManager* task_queue_manager,
@@ -50,12 +61,12 @@ class SCHEDULER_EXPORT TaskQueueImpl final : public TaskQueue {
void UpdateWorkQueue(LazyNow* lazy_now,
bool should_trigger_wakeup,
- const base::PendingTask* previous_task);
- base::PendingTask TakeTaskFromWorkQueue();
+ const SchedulerTask* previous_task);
+ SchedulerTask TakeTaskFromWorkQueue();
void WillDeleteTaskQueueManager();
- base::TaskQueue& work_queue() { return work_queue_; }
+ std::queue<SchedulerTask>& work_queue() { return work_queue_; }
WakeupPolicy wakeup_policy() const {
DCHECK(main_thread_checker_.CalledOnValidThread());
@@ -79,7 +90,7 @@ class SCHEDULER_EXPORT TaskQueueImpl final : public TaskQueue {
bool GetShouldNotifyObservers() const { return should_notify_observers_; }
// Test support functions. These should not be used in production code.
- void PushTaskOntoWorkQueueForTest(const base::PendingTask& task);
+ void PushTaskOntoWorkQueueForTest(const SchedulerTask& task);
void PopTaskFromWorkQueueForTest();
size_t WorkQueueSizeForTest() const { return work_queue_.size(); }
@@ -126,20 +137,20 @@ class SCHEDULER_EXPORT TaskQueueImpl final : public TaskQueue {
void ScheduleDelayedWorkLocked(LazyNow* lazy_now);
void PumpQueueLocked();
- bool TaskIsOlderThanQueuedTasks(const base::PendingTask* task);
+ bool TaskIsOlderThanQueuedTasks(const SchedulerTask* task);
bool ShouldAutoPumpQueueLocked(bool should_trigger_wakeup,
- const base::PendingTask* previous_task);
+ const SchedulerTask* previous_task);
// Push the task onto the |incoming_queue_| and allocate a sequence number
// for it.
- void EnqueueTaskLocked(const base::PendingTask& pending_task);
+ void EnqueueTaskLocked(const SchedulerTask& pending_task);
void TraceQueueSize(bool is_locked) const;
- static void QueueAsValueInto(const base::TaskQueue& queue,
+ static void QueueAsValueInto(const std::queue<SchedulerTask>& queue,
base::trace_event::TracedValue* state);
- static void QueueAsValueInto(const base::DelayedTaskQueue& queue,
+ static void QueueAsValueInto(const std::priority_queue<SchedulerTask>& queue,
base::trace_event::TracedValue* state);
- static void TaskAsValueInto(const base::PendingTask& task,
+ static void TaskAsValueInto(const SchedulerTask& task,
base::trace_event::TracedValue* state);
// This lock protects all members in the contigious block below.
@@ -147,13 +158,9 @@ class SCHEDULER_EXPORT TaskQueueImpl final : public TaskQueue {
mutable base::Lock lock_;
base::PlatformThreadId thread_id_;
TaskQueueManager* task_queue_manager_;
- base::TaskQueue incoming_queue_;
+ std::queue<SchedulerTask> incoming_queue_;
PumpPolicy pump_policy_;
- // Queue-local task sequence number for maintaining the order of delayed
- // tasks which are posted for the exact same time. Note that this will be
- // replaced by the global sequence number when the delay has elapsed.
- int delayed_task_sequence_number_;
- base::DelayedTaskQueue delayed_task_queue_;
+ std::priority_queue<SchedulerTask> delayed_task_queue_;
std::set<base::TimeTicks> in_flight_kick_delayed_tasks_;
const char* name_;
@@ -161,7 +168,7 @@ class SCHEDULER_EXPORT TaskQueueImpl final : public TaskQueue {
const char* disabled_by_default_verbose_tracing_category_;
base::ThreadChecker main_thread_checker_;
- base::TaskQueue work_queue_;
+ std::queue<SchedulerTask> work_queue_;
WakeupPolicy wakeup_policy_;
size_t set_index_;
bool should_monitor_quiescence_;
« no previous file with comments | « no previous file | components/scheduler/child/task_queue_impl.cc » ('j') | components/scheduler/child/task_queue_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698