diff --git a/xpcom/threads/TaskQueue.cpp b/xpcom/threads/TaskQueue.cpp index b06299f6d4f5..e3a2e6f676dd 100644 --- a/xpcom/threads/TaskQueue.cpp +++ b/xpcom/threads/TaskQueue.cpp @@ -59,7 +59,7 @@ nsresult TaskQueue::DispatchLocked(nsCOMPtr& aRunnable, } LogRunnable::LogDispatch(aRunnable); - mTasks.push({std::move(aRunnable), aFlags}); + mTasks.Push({std::move(aRunnable), aFlags}); if (mIsRunning) { return NS_OK; @@ -87,7 +87,7 @@ void TaskQueue::AwaitIdleLocked() { !AbstractThread::GetCurrent()->HasTailTasksFor(this)); mQueueMonitor.AssertCurrentThreadOwns(); - MOZ_ASSERT(mIsRunning || mTasks.empty()); + MOZ_ASSERT(mIsRunning || mTasks.IsEmpty()); while (mIsRunning) { mQueueMonitor.Wait(); } @@ -170,7 +170,7 @@ RefPtr TaskQueue::BeginShutdown() { bool TaskQueue::IsEmpty() { MonitorAutoLock mon(mQueueMonitor); - return mTasks.empty(); + return mTasks.IsEmpty(); } bool TaskQueue::IsCurrentThreadIn() const { @@ -183,14 +183,14 @@ nsresult TaskQueue::Runner::Run() { { MonitorAutoLock mon(mQueue->mQueueMonitor); MOZ_ASSERT(mQueue->mIsRunning); - if (mQueue->mTasks.empty()) { + if (mQueue->mTasks.IsEmpty()) { mQueue->mIsRunning = false; mQueue->MaybeResolveShutdown(); mon.NotifyAll(); return NS_OK; } - event = std::move(mQueue->mTasks.front()); - mQueue->mTasks.pop(); + event = std::move(mQueue->mTasks.FirstElement()); + mQueue->mTasks.Pop(); } MOZ_ASSERT(event.event); @@ -218,7 +218,7 @@ nsresult TaskQueue::Runner::Run() { { MonitorAutoLock mon(mQueue->mQueueMonitor); - if (mQueue->mTasks.empty()) { + if (mQueue->mTasks.IsEmpty()) { // No more events to run. Exit the task runner. mQueue->mIsRunning = false; mQueue->MaybeResolveShutdown(); @@ -236,7 +236,7 @@ nsresult TaskQueue::Runner::Run() { { MonitorAutoLock mon(mQueue->mQueueMonitor); rv = mQueue->mTarget->Dispatch( - this, mQueue->mTasks.front().flags | NS_DISPATCH_AT_END); + this, mQueue->mTasks.FirstElement().flags | NS_DISPATCH_AT_END); } if (NS_FAILED(rv)) { // Failed to dispatch, shutdown! diff --git a/xpcom/threads/TaskQueue.h b/xpcom/threads/TaskQueue.h index 245914299c2a..0c588fb996d0 100644 --- a/xpcom/threads/TaskQueue.h +++ b/xpcom/threads/TaskQueue.h @@ -7,12 +7,11 @@ #ifndef TaskQueue_h_ #define TaskQueue_h_ -#include - #include "mozilla/AbstractThread.h" #include "mozilla/Maybe.h" #include "mozilla/Monitor.h" #include "mozilla/MozPromise.h" +#include "mozilla/Queue.h" #include "mozilla/RefPtr.h" #include "mozilla/TaskDispatcher.h" #include "nsIDelayedRunnableObserver.h" @@ -166,7 +165,7 @@ class TaskQueue : public AbstractThread, } TaskStruct; // Queue of tasks to run. - std::queue mTasks; + Queue mTasks; // DelayedRunnables (from DelayedDispatch) that are managed by their // respective timers, but have not yet run. Accessed only on this