Bug 1441059 - Add cycle collection implementations for Maybe. r=bz a=ritu GECKOVIEW_62_RELBRANCH
☠☠ backed out by 4cdeecd31350 ☠ ☠
authorDylan Roeh <droeh@mozilla.com>
Tue, 17 Jul 2018 10:34:58 -0500
branchGECKOVIEW_62_RELBRANCH
changeset 481111 427eacc1a0bf
parent 481110 76f94cb522c7
child 481112 99aa10a241f6
push id1772
push usernchen@mozilla.com
push date2018-08-31 22:52 +0000
treeherdermozilla-release@31683bdf39d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, ritu
bugs1441059
milestone62.0
Bug 1441059 - Add cycle collection implementations for Maybe. r=bz a=ritu
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 */