Bug 1441059 - Add cycle collection implementations for Maybe. r=bz
authorDylan Roeh <droeh@mozilla.com>
Tue, 17 Jul 2018 10:34:58 -0500
changeset 427758 f7bd4f224f9aade0428b7a254248a77f89562055
parent 427757 62fd708ed9d936568e54d21b890dfd9e19703cd0
child 427759 4d132be2829d2b9bdfc169021b01e50abc61e3f0
child 427794 ff3fab43d24dfdaa8971d92cc4caaf4dc9f54dba
push id105532
push userdroeh@mozilla.com
push dateMon, 23 Jul 2018 13:19:56 +0000
treeherdermozilla-inbound@f7bd4f224f9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1441059
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1441059 - Add cycle collection implementations for Maybe. r=bz
mfbt/Maybe.h
--- a/mfbt/Maybe.h
+++ b/mfbt/Maybe.h
@@ -17,16 +17,18 @@
 #include "mozilla/OperatorNewExtensions.h"
 #include "mozilla/Poison.h"
 #include "mozilla/TypeTraits.h"
 
 #include <new>  // for placement new
 #include <ostream>
 #include <type_traits>
 
+class nsCycleCollectionTraversalCallback;
+
 namespace mozilla {
 
 struct Nothing { };
 
 namespace detail {
 
 // You would think that poisoning Maybe instances could just be a call
 // to mozWritePoison.  Unfortunately, using a simple call to
@@ -708,11 +710,33 @@ operator<=(const Maybe<T>& aLHS, const M
 }
 
 template<typename T> bool
 operator>=(const Maybe<T>& aLHS, const Maybe<T>& aRHS)
 {
   return !(aLHS < aRHS);
 }
 
+
+template<typename T>
+void
+ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
+                            Maybe<T>& aMaybe,
+                            const char* aName,
+                            uint32_t aFlags = 0)
+{
+  if (aMaybe.isSome()) {
+    ImplCycleCollectionTraverse(aCallback, aMaybe.ref(), aName, aFlags);
+  }
+}
+
+template<typename T>
+void
+ImplCycleCollectionUnlink(Maybe<T>& aMaybe)
+{
+  if (aMaybe.isSome()) {
+    ImplCycleCollectionUnlink(aMaybe.ref());
+  }
+}
+
 } // namespace mozilla
 
 #endif /* mozilla_Maybe_h */