Summary: Similar to Promise::fulfil -> setWith change, this name is a lot clearer
Test Plan: tests
Reviewed By: hans@fb.com
Subscribers: netego-diffs@, fugalh, mwa, jgehring, fuegen, folly-diffs@, tingy, jsedgwick, yfeldblum, chalfant
FB internal diff:
D2013124
Tasks:
6837405
Signature: t1:
2013124:
1429735106:
e8861925dfeb6d7f0662c1057cbcf2ad8dcf008c
F&& func,
typename std::enable_if<!std::is_reference<F>::value, bool>::type sdf)
-> Future<decltype(func())> {
F&& func,
typename std::enable_if<!std::is_reference<F>::value, bool>::type sdf)
-> Future<decltype(func())> {
-auto makeFutureTry(F const& func) -> Future<decltype(func())> {
+auto makeFutureWith(F const& func) -> Future<decltype(func())> {
- return makeFutureTry(std::move(copy));
+ return makeFutureWith(std::move(copy));
/** Make a completed Future by executing a function. If the function throws
we capture the exception, otherwise we capture the result. */
template <class F>
/** Make a completed Future by executing a function. If the function throws
we capture the exception, otherwise we capture the result. */
template <class F>
F&& func,
typename std::enable_if<
!std::is_reference<F>::value, bool>::type sdf = false)
-> Future<decltype(func())>;
template <class F>
F&& func,
typename std::enable_if<
!std::is_reference<F>::value, bool>::type sdf = false)
-> Future<decltype(func())>;
template <class F>
F const& func)
-> Future<decltype(func())>;
F const& func)
-> Future<decltype(func())>;
EXPECT_EQ(42, makeFuture<float>(42).value());
auto fun = [] { return 42; };
EXPECT_EQ(42, makeFuture<float>(42).value());
auto fun = [] { return 42; };
- EXPECT_TYPE(makeFutureTry(fun), Future<int>);
- EXPECT_EQ(42, makeFutureTry(fun).value());
+ EXPECT_TYPE(makeFutureWith(fun), Future<int>);
+ EXPECT_EQ(42, makeFutureWith(fun).value());
auto failfun = []() -> int { throw eggs; };
auto failfun = []() -> int { throw eggs; };
- EXPECT_TYPE(makeFutureTry(failfun), Future<int>);
- EXPECT_THROW(makeFutureTry(failfun).value(), eggs_t);
+ EXPECT_TYPE(makeFutureWith(failfun), Future<int>);
+ EXPECT_THROW(makeFutureWith(failfun).value(), eggs_t);
EXPECT_TYPE(makeFuture(), Future<void>);
}
EXPECT_TYPE(makeFuture(), Future<void>);
}
}
Future<void> write(Context* ctx, Win msg) override {
}
Future<void> write(Context* ctx, Win msg) override {
- return makeFutureTry([&](){
+ return makeFutureWith([&](){
write_(ctx, msg);
});
}
Future<void> close(Context* ctx) override {
write_(ctx, msg);
});
}
Future<void> close(Context* ctx) override {
- return makeFutureTry([&](){
+ return makeFutureWith([&](){