Closed Bug 1645467 Opened 4 years ago Closed 4 years ago

Return a bool for HelperThreadTaskCallback

Categories

(Core :: XPConnect, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
mozilla80
Tracking Status
firefox80 --- fixed

People

(Reporter: KrisWright, Assigned: KrisWright)

References

Details

Attachments

(1 file)

Right now, the HelperThreadTaskCallback is just a void* and the Spidermonkey side of thread pool dispatch can't interpret nsThreadPool errors. I would like to create some error struct for HelperThreadPool users to interpret errors from, to prevent further issues related to shutdown order and thread pool init. That way, if dispatch fails, Spidermonkey can handle the dispatch errors as needed.

I can see something like this working:

  • Create some DispatchResult struct for js::RunnableTask and expose it to xpconnect
  • Make HelperThreadTaskCallback and DispatchOffthreadTask return the DispatchResult struct
  • Map the nsResult errors returned by nsThreadPool to DispatchResult to get the return value

Then, on the Spidermonkey side, users of HelperThreadPool can determine how they want to handle an error (run synchronously, leak, assert).

Mostly we only need to know if the task was dispatched successfully, so returning a bool to indicate failure/success would be enough.

(In reply to Jon Coppeard (:jonco) from comment #1)

Mostly we only need to know if the task was dispatched successfully, so returning a bool to indicate failure/success would be enough.

If Spidermonkey doesn't care about what kind of failures happen then I'm not opposed to this at all as it'd be much simpler to implement.

This changes HelperThreadTaskCallback to be a bool type callback and changes DispatchOffthreadTask to return a bool type if gHelperThreads successfully dispatches. The failure will be false regardless of what kind of failure it is, but if JS doesn't care and only wants to know if there is a failure then this will be simpler than exposing a proper error enum. This also changes HelperThreadPool::Dispatch to no longer return NS_OK and instead returns whatever the nsResult from the nsThreadPool may be.

Assignee: nobody → kwright
Status: NEW → ASSIGNED

Renaming this bug to better reflect what was actually changed.

Summary: Expose some error struct for HelperThreadPool → Return a bool for HelperThreadTaskCallback
Pushed by kwright@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2aaefd56b152 Change the void-type HelperThreadTaskCallback to return a bool r=jonco
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla80
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: