Skip to content

Commit 2cb072d

Browse files
LeeHowesfacebook-github-bot
authored andcommitted
Future<T>::then Future<T>::then() -> Future<T>::thenValue or thenTry.
Summary: Part of the larger project to modify Future<T>::then to be r-value qualified and use Future<T>::thenTry or Future<T>::thenValue. The goal is to disambiguate folly::Future and to improve type and lifetime safety of Future and its methods. Codemod: future<T>.then(callable with operator()(not-a-try)) to future<T>.thenValue(callable with operator()(not-a-try)). future<T>.then(callable with operator()()) to future<T>.thenValue(callable with operator()(auto&&)). future<T>.then(callable with operator()(auto)) to future<T>.thenValue(callable with operator()(auto)). future<T>.then(callable with operator()(folly::Try<T>)) to future<T>.thenTry(callable) Reviewed By: Orvid Differential Revision: D9819433 fbshipit-source-id: f8a718f697edc4a175864cf741d18b0ab3e9ce83
1 parent f983561 commit 2cb072d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

rsocket/RSocket.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ folly::Future<std::unique_ptr<RSocketClient>> RSocket::createConnectedClient(
5656
};
5757

5858
return connectionFactory->connect(protocolVersion, ResumeStatus::NEW_SESSION)
59-
.then(
59+
.thenValue(
6060
[createRSC = std::move(createRSC)](
6161
ConnectionFactory::ConnectedDuplexConnection connection) mutable {
6262
// fromConnection method must be called from the transport eventBase
@@ -96,8 +96,10 @@ folly::Future<std::unique_ptr<RSocketClient>> RSocket::createResumedClient(
9696
std::move(coldResumeHandler),
9797
stateMachineEvb);
9898

99-
return c->resume().then([client = std::unique_ptr<RSocketClient>(
100-
c)]() mutable { return std::move(client); });
99+
return c->resume().thenValue(
100+
[client = std::unique_ptr<RSocketClient>(c)](auto&&) mutable {
101+
return std::move(client);
102+
});
101103
}
102104

103105
std::unique_ptr<RSocketClient> RSocket::createClientFromConnection(

0 commit comments

Comments
 (0)