Chromium Code Reviews| Index: third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h |
| diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h |
| index 5509bd9529136efb7f050cbe7e2c26daac04e4a4..c30540a46cf89fb3247ab49ba1691de911087150 100644 |
| --- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h |
| +++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h |
| @@ -8,6 +8,7 @@ |
| #include <map> |
| #include "base/atomic_sequence_num.h" |
| +#include "base/cancelable_callback.h" |
| #include "base/debug/task_annotator.h" |
| #include "base/macros.h" |
| #include "base/memory/weak_ptr.h" |
| @@ -18,6 +19,7 @@ |
| #include "platform/scheduler/base/enqueue_order.h" |
| #include "platform/scheduler/base/task_queue_impl.h" |
| #include "platform/scheduler/base/task_queue_selector.h" |
| +#include "wtf/SpinLock.h" |
| namespace base { |
| namespace trace_event { |
| @@ -140,6 +142,10 @@ class BLINK_PLATFORM_EXPORT TaskQueueManager |
| // Returns true if there is a task that could be executed immediately. |
| bool HasImmediateWorkForTesting() const; |
| + // There is a small overhead to recording task delay histograms. If you don't |
| + // need them, you can turn them off. |
|
Sami
2016/12/05 17:52:54
Or we could consider deleting them :) (Don't recal
alex clarke (OOO till 29th)
2016/12/06 17:37:54
Lets make that decision in a different patch?
Sami
2016/12/07 16:13:42
Sure, no problem.
|
| + void SetRecordTaskDelayHistograms(bool record_task_delay_histograms); |
| + |
| private: |
| friend class LazyNow; |
| friend class internal::TaskQueueImpl; |
| @@ -152,9 +158,6 @@ class BLINK_PLATFORM_EXPORT TaskQueueManager |
| }; |
| // Unregisters a TaskQueue previously created by |NewTaskQueue()|. |
| - // NOTE we have to flush the queue from |newly_updatable_| which means as a |
| - // side effect MoveNewlyUpdatableQueuesIntoUpdatableQueueSet is called by this |
| - // function. |
| void UnregisterTaskQueue(scoped_refptr<internal::TaskQueueImpl> task_queue); |
| // TaskQueueSelector::Observer implementation: |
| @@ -169,11 +172,11 @@ class BLINK_PLATFORM_EXPORT TaskQueueManager |
| void DidQueueTask(const internal::TaskQueueImpl::Task& pending_task); |
| // Use the selector to choose a pending task and run it. |
| - void DoWork(base::TimeTicks run_time, bool from_main_thread); |
| + void DoWork(bool delayed); |
| // Delayed Tasks with run_times <= Now() are enqueued onto the work queue and |
| // reloads any empty work queues. |
| - void UpdateWorkQueues(LazyNow lazy_now); |
| + void UpdateWorkQueues(LazyNow* lazy_now); |
| // Chooses the next work queue to service. Returns true if |out_queue| |
| // indicates the queue from which the next task should be run, false to |
| @@ -197,9 +200,9 @@ class BLINK_PLATFORM_EXPORT TaskQueueManager |
| internal::EnqueueOrder GetNextSequenceNumber(); |
| - // Calls MaybeAdvanceTime on all time domains and returns true if one of them |
| - // was able to advance. |
| - bool TryAdvanceTimeDomains(); |
| + // Calls DelayTillNextTask on all time domains and returns the smallest delay |
| + // requested if any. |
| + base::Optional<base::TimeDelta> DelayTillNextTask(LazyNow* lazy_now); |
| void MaybeRecordTaskDelayHistograms( |
| const internal::TaskQueueImpl::Task& pending_task, |
| @@ -209,6 +212,17 @@ class BLINK_PLATFORM_EXPORT TaskQueueManager |
| AsValueWithSelectorResult(bool should_run, |
| internal::WorkQueue* selected_work_queue) const; |
| + void MaybeScheduleImmediateWorkLocked( |
| + const tracked_objects::Location& from_here); |
| + |
| + void MaybeScheduleDelayedWorkInternal( |
| + const tracked_objects::Location& from_here, |
| + base::TimeTicks now, |
| + base::TimeDelta delay); |
| + |
| + void OnQueueHasImmediateWork(internal::TaskQueueImpl* queue); |
| + void NotifyQueuesOfIncomingImmediateWorkOnMainThreadLocked(); |
| + |
| std::set<TimeDomain*> time_domains_; |
| std::unique_ptr<RealTimeDomain> real_time_domain_; |
| @@ -225,18 +239,23 @@ class BLINK_PLATFORM_EXPORT TaskQueueManager |
| scoped_refptr<TaskQueueManagerDelegate> delegate_; |
| internal::TaskQueueSelector selector_; |
| - base::Closure from_main_thread_immediate_do_work_closure_; |
| - base::Closure from_other_thread_immediate_do_work_closure_; |
| + base::Closure immediate_do_work_closure_; |
| + base::Closure delayed_do_work_closure_; |
| bool task_was_run_on_quiescence_monitored_queue_; |
| - // To reduce locking overhead we track pending calls to DoWork separately for |
| - // the main thread and other threads. |
| - std::set<base::TimeTicks> main_thread_pending_wakeups_; |
| + // Protects |do_work_running_count_|, |immediate_do_work_posted_count_|, |
| + // |is_nested_| and |has_incomming_immediate_work_|. |
| + mutable WTF::SpinLock do_work_pending_lock_; |
| + int do_work_running_count_; |
| + int immediate_do_work_posted_count_; |
| + std::set<internal::TaskQueueImpl*> has_incomming_immediate_work_; |
|
Sami
2016/12/05 17:52:55
Does this need to be ordered by the way?
alex clarke (OOO till 29th)
2016/12/06 17:37:54
No. I expect this to be mostly empty, it would be
|
| + bool is_nested_; // Whether or not the message loop is currently nested. |
| + |
| + bool record_task_delay_histograms_; |
| - // Protects |other_thread_pending_wakeup_|. |
| - mutable base::Lock other_thread_lock_; |
| - bool other_thread_pending_wakeup_; |
| + base::TimeTicks next_delayed_do_work_; |
| + base::CancelableClosure cancelable_delayed_do_work_closure_; |
| int work_batch_size_; |
| size_t task_count_; |