File tree 1 file changed +11
-3
lines changed
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,15 @@ class AutoTaskDispatcher : public TaskDispatcher
124
124
already_AddRefed<nsIRunnable> aRunnable,
125
125
AbstractThread::DispatchFailureHandling aFailureHandling) override
126
126
{
127
- PerThreadTaskGroup& group = EnsureTaskGroup (aThread);
127
+ // To preserve the event order, we need to append a new group if the last
128
+ // group is not targeted for |aThread|.
129
+ // See https://bugzilla.mozilla.org/show_bug.cgi?id=1318226&mark=0-3#c0
130
+ // for the details of the issue.
131
+ if (mTaskGroups .Length () == 0 || mTaskGroups .LastElement ()->mThread != aThread) {
132
+ mTaskGroups .AppendElement (new PerThreadTaskGroup (aThread));
133
+ }
134
+
135
+ PerThreadTaskGroup& group = *mTaskGroups .LastElement ();
128
136
group.mRegularTasks .AppendElement (aRunnable);
129
137
130
138
// The task group needs to assert dispatch success if any of the runnables
@@ -142,11 +150,11 @@ class AutoTaskDispatcher : public TaskDispatcher
142
150
143
151
void DispatchTasksFor (AbstractThread* aThread) override
144
152
{
153
+ // Dispatch all groups that match |aThread|.
145
154
for (size_t i = 0 ; i < mTaskGroups .Length (); ++i) {
146
155
if (mTaskGroups [i]->mThread == aThread) {
147
156
DispatchTaskGroup (Move (mTaskGroups [i]));
148
- mTaskGroups .RemoveElementAt (i);
149
- return ;
157
+ mTaskGroups .RemoveElementAt (i--);
150
158
}
151
159
}
152
160
}
You can’t perform that action at this time.
0 commit comments