Commit b79405c6 authored by James Sedgwick's avatar James Sedgwick Committed by Alecs King

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
parent c1ad7544
...@@ -469,7 +469,7 @@ Future<void> makeFuture() { ...@@ -469,7 +469,7 @@ Future<void> makeFuture() {
} }
template <class F> template <class F>
auto makeFutureTry( auto makeFutureWith(
F&& func, F&& func,
typename std::enable_if<!std::is_reference<F>::value, bool>::type sdf) typename std::enable_if<!std::is_reference<F>::value, bool>::type sdf)
-> Future<decltype(func())> { -> Future<decltype(func())> {
...@@ -482,9 +482,9 @@ auto makeFutureTry( ...@@ -482,9 +482,9 @@ auto makeFutureTry(
} }
template <class F> template <class F>
auto makeFutureTry(F const& func) -> Future<decltype(func())> { auto makeFutureWith(F const& func) -> Future<decltype(func())> {
F copy = func; F copy = func;
return makeFutureTry(std::move(copy)); return makeFutureWith(std::move(copy));
} }
template <class T> template <class T>
......
...@@ -581,14 +581,14 @@ Future<void> makeFuture(); ...@@ -581,14 +581,14 @@ Future<void> makeFuture();
/** Make a completed Future by executing a function. If the function throws /** Make a completed Future by executing a function. If the function throws
we capture the exception, otherwise we capture the result. */ we capture the exception, otherwise we capture the result. */
template <class F> template <class F>
auto makeFutureTry( auto makeFutureWith(
F&& func, F&& func,
typename std::enable_if< typename std::enable_if<
!std::is_reference<F>::value, bool>::type sdf = false) !std::is_reference<F>::value, bool>::type sdf = false)
-> Future<decltype(func())>; -> Future<decltype(func())>;
template <class F> template <class F>
auto makeFutureTry( auto makeFutureWith(
F const& func) F const& func)
-> Future<decltype(func())>; -> Future<decltype(func())>;
......
...@@ -536,12 +536,12 @@ TEST(Future, makeFuture) { ...@@ -536,12 +536,12 @@ TEST(Future, makeFuture) {
EXPECT_EQ(42, makeFuture<float>(42).value()); EXPECT_EQ(42, makeFuture<float>(42).value());
auto fun = [] { return 42; }; auto fun = [] { return 42; };
EXPECT_TYPE(makeFutureTry(fun), Future<int>); EXPECT_TYPE(makeFutureWith(fun), Future<int>);
EXPECT_EQ(42, makeFutureTry(fun).value()); EXPECT_EQ(42, makeFutureWith(fun).value());
auto failfun = []() -> int { throw eggs; }; auto failfun = []() -> int { throw eggs; };
EXPECT_TYPE(makeFutureTry(failfun), Future<int>); EXPECT_TYPE(makeFutureWith(failfun), Future<int>);
EXPECT_THROW(makeFutureTry(failfun).value(), eggs_t); EXPECT_THROW(makeFutureWith(failfun).value(), eggs_t);
EXPECT_TYPE(makeFuture(), Future<void>); EXPECT_TYPE(makeFuture(), Future<void>);
} }
......
...@@ -57,13 +57,13 @@ class MockChannelHandler : public ChannelHandler<Rin, Rout, Win, Wout> { ...@@ -57,13 +57,13 @@ class MockChannelHandler : public ChannelHandler<Rin, Rout, Win, Wout> {
} }
Future<void> write(Context* ctx, Win msg) override { Future<void> write(Context* ctx, Win msg) override {
return makeFutureTry([&](){ return makeFutureWith([&](){
write_(ctx, msg); write_(ctx, msg);
}); });
} }
Future<void> close(Context* ctx) override { Future<void> close(Context* ctx) override {
return makeFutureTry([&](){ return makeFutureWith([&](){
close_(ctx); close_(ctx);
}); });
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment