Bug 1300118 P5 Expose the TaskQueue backlog ImpreciseLengthForHeuristics(). r=bholley
authorBen Kelly <ben@wanderview.com>
Tue, 13 Sep 2016 20:12:15 -0700
changeset 313864 f5cd6f6bc89e310091674f09f19e18f92a949aa6
parent 313863 8a8e26a6969040ec85bd9934e5fdf42db55031f6
child 313865 62775b8b0e7b7b45beec34cc1335dcd02cdcf87e
push id32264
push usercbook@mozilla.com
push dateWed, 14 Sep 2016 10:18:20 +0000
treeherderautoland@b9c4a0402a0a [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();