Closed
Bug 1055925
Opened 11 years ago
Closed 11 years ago
Refactor promise to make it simpler to run async task on main and worker thread
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla34
People
(Reporter: xyuan, Assigned: xyuan)
References
Details
Attachments
(1 file, 1 obsolete file)
15.05 KB,
patch
|
xyuan
:
review+
|
Details | Diff | Splinter Review |
The promise should be resolved asynchronously and a few async tasks are created.
With current implementation, each task needs two different classes, one for the promise running on the main thread and the other for that on the work thread.
For example, we have the pair of PromiseTask[1] and WorkerPromiseTask[2], and the pair of PromiseResolverTask[3] and WorkerPromiseResolverTask[4].
Each task pair classes do the same work except for thread specific code.
I want to strip out thread specific code from each task pair and merge each pair into one. So that we only need to create one class for each task and don't need to handle thread specific code individually for each task.
This change will faciliate bug 1035060, where we need to create new async task for abort callback.
[1] https://github.com/mozilla/gecko-dev/blob/28a6cdcb51ae87d94c054fa9d8414b919ac93afa/dom/promise/Promise.cpp#L1021
[2] https://github.com/mozilla/gecko-dev/blob/28a6cdcb51ae87d94c054fa9d8414b919ac93afa/dom/promise/Promise.cpp#L1026
[3] https://github.com/mozilla/gecko-dev/blob/28a6cdcb51ae87d94c054fa9d8414b919ac93afa/dom/promise/Promise.cpp#L1218
[4] https://github.com/mozilla/gecko-dev/blob/28a6cdcb51ae87d94c054fa9d8414b919ac93afa/dom/promise/Promise.cpp#L1224
Assignee | ||
Comment 1•11 years ago
|
||
DispatchToMainOrWorkerThread is added to enable the task runnable of the main thread to run on the worker thread. So we don't need the worker runnable any more.
This patch removes the worker task runnables, such as WorkerPromiseTask and WorkerPromiseResolverTask, and keeps only one runnable for each task.
Attachment #8475697 -
Flags: review?(nsm.nikhil)
Assignee | ||
Comment 2•11 years ago
|
||
Comment on attachment 8475697 [details] [diff] [review]
refactor task
Review of attachment 8475697 [details] [diff] [review]:
-----------------------------------------------------------------
Nice patch!
::: dom/promise/Promise.cpp
@@ +939,5 @@
> +/* static */ void
> +Promise::DispatchToMainOrWorkerThread(nsIRunnable* aRunnable)
> +{
> + MOZ_ASSERT(aRunnable);
> + if (MOZ_LIKELY(NS_IsMainThread())) {
Could you remove MOZ_LIKELY unless there is a proven performance advantage?
Attachment #8475697 -
Flags: review?(nsm.nikhil) → review+
Assignee | ||
Comment 4•11 years ago
|
||
Nikhil, thanks.
MOZ_LIKELY is removed.
Try:
https://tbpl.mozilla.org/?tree=Try&rev=71abc83c2778
https://tbpl.mozilla.org/?tree=Try&rev=71abc83c2778
Attachment #8475697 -
Attachment is obsolete: true
Attachment #8476426 -
Flags: review+
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 5•11 years ago
|
||
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•