From df7a2d078ab78d4f2a8a94c71d1b0d342f5a3bf7 Mon Sep 17 00:00:00 2001 From: James Sedgwick Date: Wed, 13 May 2015 14:07:17 -0700 Subject: [PATCH] makeTryFunction -> makeTryWith codemod 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 | 2 +- folly/experimental/fibers/FiberManager-inl.h | 4 ++-- folly/experimental/fibers/Promise-inl.h | 2 +- folly/futures/Promise-inl.h | 2 +- folly/futures/Try-inl.h | 4 ++-- folly/futures/Try.h | 6 +++--- folly/futures/test/Try.cpp | 16 ++++++++-------- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/folly/experimental/fibers/AddTasks-inl.h b/folly/experimental/fibers/AddTasks-inl.h index 1e74f63d..783a9876 100644 --- a/folly/experimental/fibers/AddTasks-inl.h +++ b/folly/experimental/fibers/AddTasks-inl.h @@ -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()) { diff --git a/folly/experimental/fibers/FiberManager-inl.h b/folly/experimental/fibers/FiberManager-inl.h index 512d59eb..97df9cab 100644 --- a/folly/experimental/fibers/FiberManager-inl.h +++ b/folly/experimental/fibers/FiberManager-inl.h @@ -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; auto f = [&func, &result]() mutable { - result = folly::makeTryFunction(std::forward(func)); + result = folly::makeTryWith(std::forward(func)); }; immediateFunc_ = std::ref(f); diff --git a/folly/experimental/fibers/Promise-inl.h b/folly/experimental/fibers/Promise-inl.h index b7e92b56..a3a4927c 100644 --- a/folly/experimental/fibers/Promise-inl.h +++ b/folly/experimental/fibers/Promise-inl.h @@ -87,7 +87,7 @@ void Promise::setValue() { template template void Promise::setWith(F&& func) { - setTry(makeTryFunction(std::forward(func))); + setTry(makeTryWith(std::forward(func))); } }} diff --git a/folly/futures/Promise-inl.h b/folly/futures/Promise-inl.h index b855d064..7019b720 100644 --- a/folly/futures/Promise-inl.h +++ b/folly/futures/Promise-inl.h @@ -127,7 +127,7 @@ template template void Promise::setWith(F&& func) { throwIfFulfilled(); - setTry(makeTryFunction(std::forward(func))); + setTry(makeTryWith(std::forward(func))); } } diff --git a/folly/futures/Try-inl.h b/folly/futures/Try-inl.h index 19287311..22bc8779 100644 --- a/folly/futures/Try-inl.h +++ b/folly/futures/Try-inl.h @@ -128,7 +128,7 @@ template typename std::enable_if< !std::is_same::type, void>::value, Try::type>>::type -makeTryFunction(F&& f) { +makeTryWith(F&& f) { typedef typename std::result_of::type ResultType; try { return Try(f()); @@ -143,7 +143,7 @@ template typename std::enable_if< std::is_same::type, void>::value, Try>::type -makeTryFunction(F&& f) { +makeTryWith(F&& f) { try { f(); return Try(); diff --git a/folly/futures/Try.h b/folly/futures/Try.h index 9e791dc3..5f5f634b 100644 --- a/folly/futures/Try.h +++ b/folly/futures/Try.h @@ -361,10 +361,10 @@ template typename std::enable_if< !std::is_same::type, void>::value, Try::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 std::enable_if< std::is_same::type, void>::value, Try>::type -makeTryFunction(F&& f); +makeTryWith(F&& f); } // folly diff --git a/folly/futures/test/Try.cpp b/folly/futures/test/Try.cpp index 69a3e0da..f0bb5d66 100644 --- a/folly/futures/test/Try.cpp +++ b/folly/futures/test/Try.cpp @@ -34,41 +34,41 @@ TEST(Try, moveOnly) { v.reserve(10); } -TEST(Try, makeTryFunction) { +TEST(Try, makeTryWith) { auto func = []() { return folly::make_unique(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(1); }; - auto result = makeTryFunction(func); + auto result = makeTryWith(func); EXPECT_TRUE(result.hasException()); } -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()); } -- 2.34.1