Bug 1318226. P1 - preserve the order of regular tasks. r=bholley

MozReview-Commit-ID: FYjbJWYDyd0

--HG--
extra : rebase_source : 1baeeb8d4e5904094bd258893d5cb59ec9ac8944
extra : intermediate-source : 224087f24319d562484be55f3b97a21f9d50577b
extra : source : b6e940be26be76ae7620037b93c98e42504ed979
This commit is contained in:
JW Wang 2017-03-08 17:11:27 +08:00
Родитель 829c0b3b86
Коммит e13f0faefe
1 изменённых файлов: 11 добавлений и 3 удалений

Просмотреть файл

@ -124,7 +124,15 @@ public:
already_AddRefed<nsIRunnable> aRunnable,
AbstractThread::DispatchFailureHandling aFailureHandling) override
{
PerThreadTaskGroup& group = EnsureTaskGroup(aThread);
// To preserve the event order, we need to append a new group if the last
// group is not targeted for |aThread|.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1318226&mark=0-3#c0
// for the details of the issue.
if (mTaskGroups.Length() == 0 || mTaskGroups.LastElement()->mThread != aThread) {
mTaskGroups.AppendElement(new PerThreadTaskGroup(aThread));
}
PerThreadTaskGroup& group = *mTaskGroups.LastElement();
group.mRegularTasks.AppendElement(aRunnable);
// The task group needs to assert dispatch success if any of the runnables
@ -142,11 +150,11 @@ public:
void DispatchTasksFor(AbstractThread* aThread) override
{
// Dispatch all groups that match |aThread|.
for (size_t i = 0; i < mTaskGroups.Length(); ++i) {
if (mTaskGroups[i]->mThread == aThread) {
DispatchTaskGroup(Move(mTaskGroups[i]));
mTaskGroups.RemoveElementAt(i);
return;
mTaskGroups.RemoveElementAt(i--);
}
}
}