Bug 1368382. P3 - remove 2 overloads of Then() using variadic template. r=gerald
authorJW Wang <jwwang@mozilla.com>
Wed, 31 May 2017 16:10:17 +0800
changeset 361729 aa971939802838b324623e709034c09346006c21
parent 361728 a6df0f5e3000f7992c9cf4e0161887a8f465a906
child 361730 d96110d766199d42524558fd83e6467906de4daf
push id31939
push usercbook@mozilla.com
push dateThu, 01 Jun 2017 11:49:28 +0000
treeherdermozilla-central@d96110d76619 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1368382
milestone55.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 1368382. P3 - remove 2 overloads of Then() using variadic template. r=gerald MozReview-Commit-ID: 9KzYGnrFoQN
xpcom/threads/MozPromise.h
--- a/xpcom/threads/MozPromise.h
+++ b/xpcom/threads/MozPromise.h
@@ -879,72 +879,38 @@ protected:
     AbstractThread* mResponseThread;
     const char* mCallSite;
     RefPtr<ThenValueType> mThenValue;
     MozPromise* mReceiver;
   };
 
 public:
   template<typename ThisType,
-           typename ResolveMethodType,
-           typename RejectMethodType,
-           typename ThenValueType =
-             ThenValue<ThisType*, ResolveMethodType, RejectMethodType>,
+           typename... Methods,
+           typename ThenValueType = ThenValue<ThisType*, Methods...>,
            typename ReturnType = ThenCommand<ThenValueType>>
   ReturnType Then(AbstractThread* aResponseThread,
                   const char* aCallSite,
                   ThisType* aThisVal,
-                  ResolveMethodType aResolveMethod,
-                  RejectMethodType aRejectMethod)
+                  Methods... aMethods)
   {
-    RefPtr<ThenValueType> thenValue = new ThenValueType(
-      aResponseThread, aThisVal, aResolveMethod, aRejectMethod, aCallSite);
-    return ReturnType(aResponseThread, aCallSite, thenValue.forget(), this);
-  }
-
-  template<
-    typename ThisType,
-    typename ResolveRejectMethodType,
-    typename ThenValueType = ThenValue<ThisType*, ResolveRejectMethodType>,
-    typename ReturnType = ThenCommand<ThenValueType>>
-  ReturnType Then(AbstractThread* aResponseThread,
-                  const char* aCallSite,
-                  ThisType* aThisVal,
-                  ResolveRejectMethodType aResolveRejectMethod)
-  {
-    RefPtr<ThenValueType> thenValue = new ThenValueType(
-      aResponseThread, aThisVal, aResolveRejectMethod, aCallSite);
+    RefPtr<ThenValueType> thenValue =
+      new ThenValueType(aResponseThread, aThisVal, aMethods..., aCallSite);
     return ReturnType(aResponseThread, aCallSite, thenValue.forget(), this);
   }
 
-  template<typename ResolveFunction,
-           typename RejectFunction,
-           typename ThenValueType = ThenValue<ResolveFunction, RejectFunction>,
+  template<typename... Functions,
+           typename ThenValueType = ThenValue<Functions...>,
            typename ReturnType = ThenCommand<ThenValueType>>
   ReturnType Then(AbstractThread* aResponseThread,
                   const char* aCallSite,
-                  ResolveFunction&& aResolveFunction,
-                  RejectFunction&& aRejectFunction)
+                  Functions&&... aFunctions)
   {
-    RefPtr<ThenValueType> thenValue = new ThenValueType(aResponseThread,
-                                                        Move(aResolveFunction),
-                                                        Move(aRejectFunction),
-                                                        aCallSite);
-    return ReturnType(aResponseThread, aCallSite, thenValue.forget(), this);
-  }
-
-  template<typename ResolveRejectFunction,
-           typename ThenValueType = ThenValue<ResolveRejectFunction>,
-           typename ReturnType = ThenCommand<ThenValueType>>
-  ReturnType Then(AbstractThread* aResponseThread,
-                  const char* aCallSite,
-                  ResolveRejectFunction&& aResolveRejectFunction)
-  {
-    RefPtr<ThenValueType> thenValue = new ThenValueType(
-      aResponseThread, Move(aResolveRejectFunction), aCallSite);
+    RefPtr<ThenValueType> thenValue =
+      new ThenValueType(aResponseThread, Move(aFunctions)..., aCallSite);
     return ReturnType(aResponseThread, aCallSite, thenValue.forget(), this);
   }
 
   void ChainTo(already_AddRefed<Private> aChainedPromise, const char* aCallSite)
   {
     MutexAutoLock lock(mMutex);
     MOZ_DIAGNOSTIC_ASSERT(!IsExclusive || !mHaveRequest);
     mHaveRequest = true;