Closed Bug 913847 Opened 6 years ago Closed 6 years ago

nsThreadUtils.h is a hub header

Categories

(Core :: XPCOM, defect)

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla27

People

(Reporter: bjacob, Assigned: bjacob)

References

(Blocks 2 open bugs)

Details

Attachments

(3 files)

A hub header is one that is included by many other headers, and itself includes many other headers. See tracking bug 912735.

This bug is about doing what we can quickly do to make it better.

First, the low-hanging fruit...
Attachment #801145 - Flags: review?(ehsan)
While doing the low-hanging fruit it was clear that many headers still have to include nsThreadUtils.h only because they need NS_IsMainThread. That function can't conveniently be forward-declared because its prototype depends on complex #ifdefs.

And while we're at it, a couple more headers only need NS_GetMainThread. So these two functions go together into a new header, MainThreadUtils.h.
Attachment #801147 - Flags: review?(ehsan)
Blocks: 913869
Blocks: includehell
Attachment #801145 - Flags: review?(ehsan) → review+
Comment on attachment 801147 [details] [diff] [review]
Split NS_IsMainThread and NS_GetMainThread into a new MainThreadUtils.h header

Review of attachment 801147 [details] [diff] [review]:
-----------------------------------------------------------------

::: xpcom/glue/MainThreadUtils.h
@@ +3,5 @@
> +/* This Source Code Form is subject to the terms of the Mozilla Public
> + * License, v. 2.0. If a copy of the MPL was not distributed with this
> + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
> +
> +#ifndef IsMainThread_h_

Nit: MainThreadUtils_h
Attachment #801147 - Flags: review?(ehsan) → review+
Attachment #801148 - Flags: review?(ehsan) → review+
(was backed out for leaks)
@#$#$%^ NS_GetMainThread() addrefs its result!!

Of course! After all, we wouldn't want the main thread to go away under our feet!!

And of course, raw pointers are strong pointers, everyone knows that!
(In reply to Benoit Jacob [:bjacob] from comment #13)
> @#$#$%^ NS_GetMainThread() addrefs its result!!

Well, its an xpcom thing and those add ref out args...

Of course we should totally decom it if there isn'ta already such a version.
You need to log in before you can comment on or make changes to this bug.