makeTryFunction -> makeTryWith codemod
authorJames Sedgwick <jsedgwick@fb.com>
Wed, 13 May 2015 21:07:17 +0000 (14:07 -0700)
committerViswanath Sivakumar <viswanath@fb.com>
Wed, 20 May 2015 17:57:01 +0000 (10:57 -0700)
Summary: This is more consistent with setWith, makeFutureWith, etc

Test Plan: unit

Reviewed By: hans@fb.com

Subscribers: folly-diffs@, jsedgwick, yfeldblum, chalfant

FB internal diff: D2064667

Signature: t1:2064667:1431541614:a0e3f23d5effde13a93ce58ca3e21c7c3575215c

folly/experimental/fibers/AddTasks-inl.h
folly/experimental/fibers/FiberManager-inl.h
folly/experimental/fibers/Promise-inl.h
folly/futures/Promise-inl.h
folly/futures/Try-inl.h
folly/futures/Try.h
folly/futures/test/Try.cpp

index 1e74f63d09c329700a4d6d83eda0b67774bb7ddb..783a987659dc3945bbeb03aac6d198b9eb70a345 100644 (file)
@@ -115,7 +115,7 @@ addTasks(InputIterator first, InputIterator last) {
 #endif
     addTask(
       [i, context, f = std::move(*first)]() {
-        context->results.emplace_back(i, folly::makeTryFunction(std::move(f)));
+        context->results.emplace_back(i, folly::makeTryWith(std::move(f)));
 
         // Check for awaiting iterator.
         if (context->promise.hasValue()) {
index 512d59eb7f2b365ad35d1cfe2c0b23f350c03d76..97df9cab20b7cdbdf0926c85873d2bac2f9c2f79 100644 (file)
@@ -309,7 +309,7 @@ struct FiberManager::AddTaskFinallyHelper {
         func_(std::move(func)), result_(finally.result_) {}
 
     void operator()() {
-      result_ = folly::makeTryFunction(std::move(func_));
+      result_ = folly::makeTryWith(std::move(func_));
 
       if (allocateInBuffer) {
         this->~Func();
@@ -387,7 +387,7 @@ FiberManager::runInMainContextHelper(F&& func) {
 
   folly::Try<Result> result;
   auto f = [&func, &result]() mutable {
-    result = folly::makeTryFunction(std::forward<F>(func));
+    result = folly::makeTryWith(std::forward<F>(func));
   };
 
   immediateFunc_ = std::ref(f);
index b7e92b561b781286f00c03a7dc8f696d226846ad..a3a4927cbd83746cf29fa4c4991c43bf59a08cb5 100644 (file)
@@ -87,7 +87,7 @@ void Promise<T>::setValue() {
 template <class T>
 template <class F>
 void Promise<T>::setWith(F&& func) {
-  setTry(makeTryFunction(std::forward<F>(func)));
+  setTry(makeTryWith(std::forward<F>(func)));
 }
 
 }}
index b855d064e90a9b826b3459989d9029de9d38527c..7019b72014598fd65c393e46fb94e1bb9f574a7e 100644 (file)
@@ -127,7 +127,7 @@ template <class T>
 template <class F>
 void Promise<T>::setWith(F&& func) {
   throwIfFulfilled();
-  setTry(makeTryFunction(std::forward<F>(func)));
+  setTry(makeTryWith(std::forward<F>(func)));
 }
 
 }
index 192873116cf53856bada4973451ca9143fe13449..22bc87796a2c46e6709c92773032c8e5302b412c 100644 (file)
@@ -128,7 +128,7 @@ template <typename F>
 typename std::enable_if<
   !std::is_same<typename std::result_of<F()>::type, void>::value,
   Try<typename std::result_of<F()>::type>>::type
-makeTryFunction(F&& f) {
+makeTryWith(F&& f) {
   typedef typename std::result_of<F()>::type ResultType;
   try {
     return Try<ResultType>(f());
@@ -143,7 +143,7 @@ template <typename F>
 typename std::enable_if<
   std::is_same<typename std::result_of<F()>::type, void>::value,
   Try<void>>::type
-makeTryFunction(F&& f) {
+makeTryWith(F&& f) {
   try {
     f();
     return Try<void>();
index 9e791dc3f6eab6188057b8c73364a0a19c0a60bd..5f5f634b2d984e515f00237e0ab0a7e260edac81 100644 (file)
@@ -361,10 +361,10 @@ template <typename F>
 typename std::enable_if<
   !std::is_same<typename std::result_of<F()>::type, void>::value,
   Try<typename std::result_of<F()>::type>>::type
-makeTryFunction(F&& f);
+makeTryWith(F&& f);
 
 /*
- * Specialization of makeTryFunction for void
+ * Specialization of makeTryWith for void
  *
  * @param f a function to execute and capture the result of
  *
@@ -374,7 +374,7 @@ template <typename F>
 typename std::enable_if<
   std::is_same<typename std::result_of<F()>::type, void>::value,
   Try<void>>::type
-makeTryFunction(F&& f);
+makeTryWith(F&& f);
 
 } // folly
 
index 69a3e0daea2ac4d15ddaacb39f3e23a16c89472d..f0bb5d66c6d1f9e7549f1939520fab36ccc1e85b 100644 (file)
@@ -34,41 +34,41 @@ TEST(Try, moveOnly) {
   v.reserve(10);
 }
 
-TEST(Try, makeTryFunction) {
+TEST(Try, makeTryWith) {
   auto func = []() {
     return folly::make_unique<int>(1);
   };
 
-  auto result = makeTryFunction(func);
+  auto result = makeTryWith(func);
   EXPECT_TRUE(result.hasValue());
   EXPECT_EQ(*result.value(), 1);
 }
 
-TEST(Try, makeTryFunctionThrow) {
+TEST(Try, makeTryWithThrow) {
   auto func = []() {
     throw std::runtime_error("Runtime");
     return folly::make_unique<int>(1);
   };
 
-  auto result = makeTryFunction(func);
+  auto result = makeTryWith(func);
   EXPECT_TRUE(result.hasException<std::runtime_error>());
 }
 
-TEST(Try, makeTryFunctionVoid) {
+TEST(Try, makeTryWithVoid) {
   auto func = []() {
     return;
   };
 
-  auto result = makeTryFunction(func);
+  auto result = makeTryWith(func);
   EXPECT_TRUE(result.hasValue());
 }
 
-TEST(Try, makeTryFunctionVoidThrow) {
+TEST(Try, makeTryWithVoidThrow) {
   auto func = []() {
     throw std::runtime_error("Runtime");
     return;
   };
 
-  auto result = makeTryFunction(func);
+  auto result = makeTryWith(func);
   EXPECT_TRUE(result.hasException<std::runtime_error>());
 }