Bug 1300118 P5 Expose the TaskQueue backlog ImpreciseLengthForHeuristics(). r=bholley
authorBen Kelly <ben@wanderview.com>
Mon, 12 Sep 2016 11:21:01 -0700
changeset 313576 6f40bffecd83c229bbbe7c75afada19296b99d90
parent 313575 fba3a9f229cff78338c8c647012cd5921c6acd86
child 313577 9b67fecfa03618779a4560f21318d1dbf67c867d
push id30694
push usercbook@mozilla.com
push dateTue, 13 Sep 2016 09:58:08 +0000
treeherdermozilla-central@f5d043ce6d36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1300118
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1300118 P5 Expose the TaskQueue backlog ImpreciseLengthForHeuristics(). r=bholley
xpcom/threads/TaskQueue.cpp
xpcom/threads/TaskQueue.h
--- a/xpcom/threads/TaskQueue.cpp
+++ b/xpcom/threads/TaskQueue.cpp
@@ -182,16 +182,23 @@ TaskQueue::BeginShutdown()
 
 bool
 TaskQueue::IsEmpty()
 {
   MonitorAutoLock mon(mQueueMonitor);
   return mTasks.empty();
 }
 
+uint32_t
+TaskQueue::ImpreciseLengthForHeuristics()
+{
+  MonitorAutoLock mon(mQueueMonitor);
+  return mTasks.size();
+}
+
 bool
 TaskQueue::IsCurrentThreadIn()
 {
   bool in = NS_GetCurrentThread() == mRunningThread;
   return in;
 }
 
 already_AddRefed<nsIEventTarget>
--- a/xpcom/threads/TaskQueue.h
+++ b/xpcom/threads/TaskQueue.h
@@ -85,16 +85,17 @@ public:
   // Blocks until all task finish executing.
   void AwaitIdle();
 
   // Blocks until the queue is flagged for shutdown and all tasks have finished
   // executing.
   void AwaitShutdownAndIdle();
 
   bool IsEmpty();
+  uint32_t ImpreciseLengthForHeuristics();
 
   // Returns true if the current thread is currently running a Runnable in
   // the task queue.
   bool IsCurrentThreadIn() override;
 
   // Create a new nsIEventTarget wrapper object that dispatches to this
   // TaskQueue.
   already_AddRefed<nsIEventTarget> WrapAsEventTarget();