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

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: Moved Task struct 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..3e6aea4e521218393c63af049130d09707627691 100644
--- a/components/scheduler/child/task_queue_impl.h
+++ b/components/scheduler/child/task_queue_impl.h
@@ -27,6 +27,18 @@ class SCHEDULER_EXPORT TaskQueueImpl final : public TaskQueue {
const char* disabled_by_default_tracing_category,
const char* disabled_by_default_verbose_tracing_category);
+ struct Task : public base::PendingTask {
+ Task(const tracked_objects::Location& posted_from,
+ const base::Closure& task,
+ int sequence_number,
+ bool nestable);
+
+ // Similar to sequence number, but the |enqueue_order| is set by
+ // EnqueueTasksLocked and is not initially defined for delayed tasks until
+ // they are enqueued on the |incoming_queue_|.
+ int enqueue_order;
+ };
+
// TaskQueue implementation.
bool RunsTasksOnCurrentThread() const override;
bool PostDelayedTask(const tracked_objects::Location& from_here,
@@ -51,11 +63,11 @@ class SCHEDULER_EXPORT TaskQueueImpl final : public TaskQueue {
void UpdateWorkQueue(LazyNow* lazy_now,
bool should_trigger_wakeup,
const base::PendingTask* previous_task);
- base::PendingTask TakeTaskFromWorkQueue();
+ Task TakeTaskFromWorkQueue();
void WillDeleteTaskQueueManager();
- base::TaskQueue& work_queue() { return work_queue_; }
+ std::queue<Task>& work_queue() { return work_queue_; }
WakeupPolicy wakeup_policy() const {
DCHECK(main_thread_checker_.CalledOnValidThread());
@@ -70,16 +82,16 @@ class SCHEDULER_EXPORT TaskQueueImpl final : public TaskQueue {
void set_task_queue_set_index(size_t set_index) { set_index_ = set_index; }
- // If the work queue isn't empty, |age| gets set to the sequence number of the
- // front task and the dunctio returns true. Otherwise the function returns
- // false.
- bool GetWorkQueueFrontTaskAge(int* age) const;
+ // If the work queue isn't empty, |enqueue_order| gets set to the sequence
Sami 2015/08/05 14:51:15 nit: s/sequence number/enqueue order/ right?
alex clarke (OOO till 29th) 2015/08/05 15:33:05 Done.
+ // number of the front task and the function returns true. Otherwise the
+ // function returns false.
+ bool GetWorkQueueFrontTaskEnqueueOrder(int* enqueue_order) const;
bool GetQuiescenceMonitored() const { return should_monitor_quiescence_; }
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 Task& task);
void PopTaskFromWorkQueueForTest();
size_t WorkQueueSizeForTest() const { return work_queue_.size(); }
@@ -130,16 +142,19 @@ class SCHEDULER_EXPORT TaskQueueImpl final : public TaskQueue {
bool ShouldAutoPumpQueueLocked(bool should_trigger_wakeup,
const base::PendingTask* previous_task);
- // Push the task onto the |incoming_queue_| and allocate a sequence number
- // for it.
- void EnqueueTaskLocked(const base::PendingTask& pending_task);
+ enum class EnqueueOrderPolicy { SET_ENQUEUE_ORDER, DONT_SET_ENQUEUE_ORDER };
+
+ // Push the task onto the |incoming_queue_| and maybe allocate an
+ // enqueue_order for it based on |enqueue_order_policy|.
+ void EnqueueTaskLocked(const Task& pending_task,
+ EnqueueOrderPolicy enqueue_order_policy);
void TraceQueueSize(bool is_locked) const;
- static void QueueAsValueInto(const base::TaskQueue& queue,
+ static void QueueAsValueInto(const std::queue<Task>& queue,
base::trace_event::TracedValue* state);
- static void QueueAsValueInto(const base::DelayedTaskQueue& queue,
+ static void QueueAsValueInto(const std::priority_queue<Task>& queue,
base::trace_event::TracedValue* state);
- static void TaskAsValueInto(const base::PendingTask& task,
+ static void TaskAsValueInto(const Task& task,
base::trace_event::TracedValue* state);
// This lock protects all members in the contigious block below.
@@ -147,13 +162,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<Task> 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<Task> delayed_task_queue_;
std::set<base::TimeTicks> in_flight_kick_delayed_tasks_;
const char* name_;
@@ -161,7 +172,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<Task> 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