diff options
author | trav90 <travawine@openmailbox.org> | 2017-10-05 00:22:00 -0500 |
---|---|---|
committer | trav90 <travawine@openmailbox.org> | 2017-10-05 00:22:00 -0500 |
commit | a7fe2ab7fb2bcc83f625639d3bdf4aed6b7a266d (patch) | |
tree | 6759c897f8b5bbc8146672d85f91688aa0217872 | |
parent | 47b806fc29c644124ab4ab11bcb2459694c375b3 (diff) | |
download | palemoon-gre-a7fe2ab7fb2bcc83f625639d3bdf4aed6b7a266d.tar.gz |
Implement TaskDispatcher::DispatchTasksFor
-rw-r--r-- | dom/media/TaskDispatcher.h | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/dom/media/TaskDispatcher.h b/dom/media/TaskDispatcher.h index faf6cc381..b1399fab8 100644 --- a/dom/media/TaskDispatcher.h +++ b/dom/media/TaskDispatcher.h @@ -56,6 +56,7 @@ public: already_AddRefed<nsIRunnable> aRunnable, AbstractThread::DispatchFailureHandling aFailureHandling = AbstractThread::AssertDispatchSuccess) = 0; + virtual void DispatchTasksFor(AbstractThread* aThread) = 0; virtual bool HasTasksFor(AbstractThread* aThread) = 0; virtual void DrainDirectTasks() = 0; }; @@ -82,14 +83,7 @@ public: MOZ_ASSERT(mDirectTasks.empty()); for (size_t i = 0; i < mTaskGroups.Length(); ++i) { - UniquePtr<PerThreadTaskGroup> group(Move(mTaskGroups[i])); - nsRefPtr<AbstractThread> thread = group->mThread; - - AbstractThread::DispatchFailureHandling failureHandling = group->mFailureHandling; - AbstractThread::DispatchReason reason = mIsTailDispatcher ? AbstractThread::TailDispatch - : AbstractThread::NormalDispatch; - nsCOMPtr<nsIRunnable> r = new TaskGroupRunnable(Move(group)); - thread->Dispatch(r.forget(), failureHandling, reason); + DispatchTaskGroup(Move(mTaskGroups[i])); } } @@ -132,6 +126,17 @@ public: return !!GetTaskGroup(aThread) || (aThread == AbstractThread::GetCurrent() && !mDirectTasks.empty()); } + void DispatchTasksFor(AbstractThread* aThread) override + { + for (size_t i = 0; i < mTaskGroups.Length(); ++i) { + if (mTaskGroups[i]->mThread == aThread) { + DispatchTaskGroup(Move(mTaskGroups[i])); + mTaskGroups.RemoveElementAt(i); + return; + } + } + } + private: struct PerThreadTaskGroup @@ -215,6 +220,17 @@ private: return nullptr; } + void DispatchTaskGroup(UniquePtr<PerThreadTaskGroup> aGroup) + { + nsRefPtr<AbstractThread> thread = aGroup->mThread; + + AbstractThread::DispatchFailureHandling failureHandling = aGroup->mFailureHandling; + AbstractThread::DispatchReason reason = mIsTailDispatcher ? AbstractThread::TailDispatch + : AbstractThread::NormalDispatch; + nsCOMPtr<nsIRunnable> r = new TaskGroupRunnable(Move(aGroup)); + thread->Dispatch(r.forget(), failureHandling, reason); + } + // Direct tasks. std::queue<nsCOMPtr<nsIRunnable>> mDirectTasks; |