diff --git a/xpcom/threads/TaskQueue.cpp b/xpcom/threads/TaskQueue.cpp index e0092cf0b9eb..1012ccd70d19 100644 --- a/xpcom/threads/TaskQueue.cpp +++ b/xpcom/threads/TaskQueue.cpp @@ -89,8 +89,8 @@ TaskQueue::TaskQueue(already_AddRefed aTarget, TaskQueue::~TaskQueue() { - MonitorAutoLock mon(mQueueMonitor); - MOZ_ASSERT(mIsShutdown); + // No one is referencing this TaskQueue anymore, meaning no tasks can be + // pending as all Runner hold a reference to this TaskQueue. } TaskDispatcher& @@ -178,7 +178,6 @@ TaskQueue::BeginShutdown() if (AbstractThread* currentThread = AbstractThread::GetCurrent()) { currentThread->TailDispatchTasksFor(this); } - MonitorAutoLock mon(mQueueMonitor); mIsShutdown = true; RefPtr p = mShutdownPromise.Ensure(__func__); diff --git a/xpcom/threads/TaskQueue.h b/xpcom/threads/TaskQueue.h index 6fc6f1b5db98..b8cc624a04b4 100644 --- a/xpcom/threads/TaskQueue.h +++ b/xpcom/threads/TaskQueue.h @@ -45,6 +45,10 @@ typedef MozPromise ShutdownPromise; // This arrangement lets you prioritize work by dispatching runnables directly // to TQ1. You can issue many runnables for important work. Meanwhile the TQ2 // and TQ3 work will always execute at most one runnable and then yield. +// +// A TaskQueue does not require explicit shutdown, however it provides a +// BeginShutdown() method that places TaskQueue in a shut down state and returns +// a promise that gets resolved once all pending tasks have completed class TaskQueue : public AbstractThread { class EventTargetWrapper;