#endif
addTask(
[i, context, f = std::move(*first)]() {
#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()) {
// Check for awaiting iterator.
if (context->promise.hasValue()) {
func_(std::move(func)), result_(finally.result_) {}
void operator()() {
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();
if (allocateInBuffer) {
this->~Func();
folly::Try<Result> result;
auto f = [&func, &result]() mutable {
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);
};
immediateFunc_ = std::ref(f);
template <class T>
template <class F>
void Promise<T>::setWith(F&& func) {
template <class T>
template <class F>
void Promise<T>::setWith(F&& func) {
- setTry(makeTryFunction(std::forward<F>(func)));
+ setTry(makeTryWith(std::forward<F>(func)));
template <class F>
void Promise<T>::setWith(F&& func) {
throwIfFulfilled();
template <class F>
void Promise<T>::setWith(F&& func) {
throwIfFulfilled();
- setTry(makeTryFunction(std::forward<F>(func)));
+ setTry(makeTryWith(std::forward<F>(func)));
typename std::enable_if<
!std::is_same<typename std::result_of<F()>::type, void>::value,
Try<typename std::result_of<F()>::type>>::type
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) {
typedef typename std::result_of<F()>::type ResultType;
try {
return Try<ResultType>(f());
typedef typename std::result_of<F()>::type ResultType;
try {
return Try<ResultType>(f());
typename std::enable_if<
std::is_same<typename std::result_of<F()>::type, void>::value,
Try<void>>::type
typename std::enable_if<
std::is_same<typename std::result_of<F()>::type, void>::value,
Try<void>>::type
-makeTryFunction(F&& f) {
try {
f();
return Try<void>();
try {
f();
return Try<void>();
typename std::enable_if<
!std::is_same<typename std::result_of<F()>::type, void>::value,
Try<typename std::result_of<F()>::type>>::type
typename std::enable_if<
!std::is_same<typename std::result_of<F()>::type, void>::value,
Try<typename std::result_of<F()>::type>>::type
- * Specialization of makeTryFunction for void
+ * Specialization of makeTryWith for void
*
* @param f a function to execute and capture the result of
*
*
* @param f a function to execute and capture the result of
*
typename std::enable_if<
std::is_same<typename std::result_of<F()>::type, void>::value,
Try<void>>::type
typename std::enable_if<
std::is_same<typename std::result_of<F()>::type, void>::value,
Try<void>>::type
-TEST(Try, makeTryFunction) {
+TEST(Try, makeTryWith) {
auto func = []() {
return folly::make_unique<int>(1);
};
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);
}
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 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>());
}
EXPECT_TRUE(result.hasException<std::runtime_error>());
}
-TEST(Try, makeTryFunctionVoid) {
+TEST(Try, makeTryWithVoid) {
auto func = []() {
return;
};
auto func = []() {
return;
};
- auto result = makeTryFunction(func);
+ auto result = makeTryWith(func);
EXPECT_TRUE(result.hasValue());
}
EXPECT_TRUE(result.hasValue());
}
-TEST(Try, makeTryFunctionVoidThrow) {
+TEST(Try, makeTryWithVoidThrow) {
auto func = []() {
throw std::runtime_error("Runtime");
return;
};
auto func = []() {
throw std::runtime_error("Runtime");
return;
};
- auto result = makeTryFunction(func);
+ auto result = makeTryWith(func);
EXPECT_TRUE(result.hasException<std::runtime_error>());
}
EXPECT_TRUE(result.hasException<std::runtime_error>());
}