mirror of
https://github.com/clearlinux/folly.git
synced 2026-09-01 02:34:43 +00:00
makeFutureTry -> makeFutureWith
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
This commit is contained in:
committed by
Alecs King
parent
c1ad75447b
commit
b79405c612
@@ -469,7 +469,7 @@ Future<void> makeFuture() {
|
||||
}
|
||||
|
||||
template <class F>
|
||||
auto makeFutureTry(
|
||||
auto makeFutureWith(
|
||||
F&& func,
|
||||
typename std::enable_if<!std::is_reference<F>::value, bool>::type sdf)
|
||||
-> Future<decltype(func())> {
|
||||
@@ -482,9 +482,9 @@ auto makeFutureTry(
|
||||
}
|
||||
|
||||
template <class F>
|
||||
auto makeFutureTry(F const& func) -> Future<decltype(func())> {
|
||||
auto makeFutureWith(F const& func) -> Future<decltype(func())> {
|
||||
F copy = func;
|
||||
return makeFutureTry(std::move(copy));
|
||||
return makeFutureWith(std::move(copy));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
||||
@@ -581,14 +581,14 @@ Future<void> makeFuture();
|
||||
/** Make a completed Future by executing a function. If the function throws
|
||||
we capture the exception, otherwise we capture the result. */
|
||||
template <class F>
|
||||
auto makeFutureTry(
|
||||
auto makeFutureWith(
|
||||
F&& func,
|
||||
typename std::enable_if<
|
||||
!std::is_reference<F>::value, bool>::type sdf = false)
|
||||
-> Future<decltype(func())>;
|
||||
|
||||
template <class F>
|
||||
auto makeFutureTry(
|
||||
auto makeFutureWith(
|
||||
F const& func)
|
||||
-> Future<decltype(func())>;
|
||||
|
||||
|
||||
@@ -536,12 +536,12 @@ TEST(Future, makeFuture) {
|
||||
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; };
|
||||
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>);
|
||||
}
|
||||
|
||||
@@ -57,13 +57,13 @@ class MockChannelHandler : public ChannelHandler<Rin, Rout, Win, Wout> {
|
||||
}
|
||||
|
||||
Future<void> write(Context* ctx, Win msg) override {
|
||||
return makeFutureTry([&](){
|
||||
return makeFutureWith([&](){
|
||||
write_(ctx, msg);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> close(Context* ctx) override {
|
||||
return makeFutureTry([&](){
|
||||
return makeFutureWith([&](){
|
||||
close_(ctx);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user