This was just landed on inbound. Cheers,
-- Ehsan <http://ehsanakhgari.org/> On Tue, Feb 25, 2014 at 9:18 PM, Ehsan Akhgari <ehsan.akhg...@gmail.com>wrote: > Over in bug 935778, I'm making RefCounted opt into the leak detection > facilities of XPCOM. This means that soon you will have to consider the > following before using RefCounted: > > 1. You should make sure that the consumers of your code either all live in > libxul or they all live outside of it. If they live in libxul, you will > get leak detection support. If they live elsewhere (such as js, or > gkmedias), you will not get leak checking. If some consumers live in > libxul and some live outside of it, you should *not* use RefCounted. > > 2. For every class that inherits from RefCounted, you need to add a macro > to your class, such as: > > class Foo : public mozilla::RefCounted<Foo> > { > public: > // This should go in the public section > MOZ_DECLARE_REFCOUNTED_TYPENAME(Foo) > // ... > }; > > If you have other classes derived this class, you need to use an alternate > macro: > > class Base : public mozilla::RefCounted<Base> > { > public: > MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(Base) > }; > > class Derived : public Base > { > public: > MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(Derived) > }; > > If you forget to add these macros, your code will not compile. If you > forget to use the virtual macros, you will confuse the leak detector and > will need to debug it. > > 3. For every class that inherits from mozilla::SupportsWeakPtr, you will > need to add macros similar to the above. > > > Please note that even with these changes, the RefCounted class is still > not on feature parity with NS_INLINE_DECL_REFCOUNTING in that it doesn't > include thread safety assertions, so it won't detect those types of bugs > for you. Therefore, I would like to *discourage* everyone from using this > class until somebody adds that feature to RefCounted. And now that you > will need to use macros with RefCounted, using it is actually harder and > less beautiful than NS_INLINE_DECL_REFCOUNTING. > > Cheers, > Ehsan > _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform