Future<T>::then 4/n: Future<T>::then(not-try-task) -> Future<T>::thenValue(task) xplat.

Summary:
Overall plan 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.

4/n: Codemod:
 * rvalue-future<T>.then(callable with operator()(not-a-try)) to rvalue-future<T>.thenValue(callable with operator()(not-a-try)).
 * rvalue-future<T>.then(callable with operator()()) to rvalue-future<T>.thenValue(callable with operator()(auto&&)).
 * rvalue-future<T>.then(callable with operator()(auto)) to rvalue-future<T>.thenValue(callable with operator()(auto)).

 Applied to xplat.

Reviewed By: marshallcline

Differential Revision: D9133114

fbshipit-source-id: 30cc4f0480ca04b3abda54af3aafd9fc4dfdf0e0
This commit is contained in:
Lee Howes
2018-08-02 16:51:21 -07:00
committed by Facebook Github Bot
parent 6dcbf94084
commit 092484e255

View File

@@ -102,7 +102,7 @@ void SonarWebSocketImpl::start() {
folly::makeFuture()
.via(sonarEventBase_->getEventBase())
.delayed(std::chrono::milliseconds(0))
.then([this]() { startSync(); });
.thenValue([this](auto&&){ startSync(); });
}
void SonarWebSocketImpl::startSync() {
@@ -192,7 +192,7 @@ void SonarWebSocketImpl::reconnect() {
folly::makeFuture()
.via(sonarEventBase_->getEventBase())
.delayed(std::chrono::seconds(reconnectIntervalSeconds))
.then([this]() { startSync(); });
.thenValue([this](auto&&){ startSync(); });
}
void SonarWebSocketImpl::stop() {