mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
[] Future<T>::then Future<T>::then(not-try-task) -> Future<T>::thenValue(task). - 2/11
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)). Reviewed By: Orvid Differential Revision: D9696716 fbshipit-source-id: d71433c75af8422b2f16733c0b18a417d5a4cf2e
This commit is contained in:
parent
bdf73e42de
commit
f28ef8281c
@ -113,9 +113,9 @@ Future<Unit> TreeDiffer::diffCommits(Hash hash1, Hash hash2) {
|
||||
auto future1 = store_->getTreeForCommit(hash1);
|
||||
auto future2 = store_->getTreeForCommit(hash2);
|
||||
return collect(future1, future2)
|
||||
.then([this](std::tuple<
|
||||
std::shared_ptr<const Tree>,
|
||||
std::shared_ptr<const Tree>>&& tup) {
|
||||
.thenValue([this](std::tuple<
|
||||
std::shared_ptr<const Tree>,
|
||||
std::shared_ptr<const Tree>>&& tup) {
|
||||
auto tree1 = std::get<0>(tup);
|
||||
auto tree2 = std::get<1>(tup);
|
||||
return diffTrees(RelativePathPiece{}, *tree1, *tree2);
|
||||
|
@ -170,7 +170,7 @@ folly::Future<std::vector<StoreResult>> LocalStore::getBatch(
|
||||
|
||||
folly::Future<std::unique_ptr<Tree>> LocalStore::getTree(const Hash& id) const {
|
||||
return getFuture(KeySpace::TreeFamily, id.getBytes())
|
||||
.then([id](StoreResult&& data) {
|
||||
.thenValue([id](StoreResult&& data) {
|
||||
if (!data.isValid()) {
|
||||
return std::unique_ptr<Tree>(nullptr);
|
||||
}
|
||||
@ -180,7 +180,7 @@ folly::Future<std::unique_ptr<Tree>> LocalStore::getTree(const Hash& id) const {
|
||||
|
||||
folly::Future<std::unique_ptr<Blob>> LocalStore::getBlob(const Hash& id) const {
|
||||
return getFuture(KeySpace::BlobFamily, id.getBytes())
|
||||
.then([id](StoreResult&& data) {
|
||||
.thenValue([id](StoreResult&& data) {
|
||||
if (!data.isValid()) {
|
||||
return std::unique_ptr<Blob>(nullptr);
|
||||
}
|
||||
@ -192,7 +192,7 @@ folly::Future<std::unique_ptr<Blob>> LocalStore::getBlob(const Hash& id) const {
|
||||
folly::Future<Optional<BlobMetadata>> LocalStore::getBlobMetadata(
|
||||
const Hash& id) const {
|
||||
return getFuture(KeySpace::BlobMetaDataFamily, id.getBytes())
|
||||
.then([id](StoreResult&& data) -> Optional<BlobMetadata> {
|
||||
.thenValue([id](StoreResult&& data) -> Optional<BlobMetadata> {
|
||||
if (!data.isValid()) {
|
||||
return folly::none;
|
||||
} else {
|
||||
|
@ -64,7 +64,7 @@ Future<shared_ptr<const Tree>> ObjectStore::getTree(const Hash& id) const {
|
||||
// this layer.
|
||||
|
||||
// Load the tree from the BackingStore.
|
||||
return backingStore->getTree(id).then(
|
||||
return backingStore->getTree(id).thenValue(
|
||||
[id](unique_ptr<const Tree> loadedTree) {
|
||||
if (!loadedTree) {
|
||||
// TODO: Perhaps we should do some short-term negative caching?
|
||||
@ -142,7 +142,7 @@ Future<shared_ptr<const Tree>> ObjectStore::getTreeForCommit(
|
||||
const Hash& commitID) const {
|
||||
XLOG(DBG3) << "getTreeForCommit(" << commitID << ")";
|
||||
|
||||
return backingStore_->getTreeForCommit(commitID).then(
|
||||
return backingStore_->getTreeForCommit(commitID).thenValue(
|
||||
[commitID](std::shared_ptr<const Tree> tree) {
|
||||
if (!tree) {
|
||||
throw std::domain_error(folly::to<string>(
|
||||
|
@ -177,7 +177,7 @@ Future<unique_ptr<Tree>> GitBackingStore::getTreeForCommit(
|
||||
Hash treeID = oid2Hash(git_commit_tree_id(commit));
|
||||
|
||||
// Now get the specified tree.
|
||||
return localStore_->getTree(treeID).then(
|
||||
return localStore_->getTree(treeID).thenValue(
|
||||
[this, treeID](unique_ptr<Tree> tree) {
|
||||
if (tree) {
|
||||
return tree;
|
||||
|
@ -168,7 +168,7 @@ folly::Future<folly::Unit> HgBackingStore::prefetchBlobs(
|
||||
const std::vector<Hash>& ids) const {
|
||||
return HgProxyHash::getBatch(localStore_, ids)
|
||||
.via(importThreadPool_.get())
|
||||
.then([](std::vector<std::pair<RelativePath, Hash>>&& hgPathHashes) {
|
||||
.thenValue([](std::vector<std::pair<RelativePath, Hash>>&& hgPathHashes) {
|
||||
return getThreadLocalImporter().prefetchFiles(hgPathHashes);
|
||||
})
|
||||
.via(serverThreadPool_);
|
||||
@ -185,7 +185,7 @@ folly::Future<unique_ptr<Tree>> HgBackingStore::getTreeForCommitImpl(
|
||||
const Hash& commitID) {
|
||||
return localStore_
|
||||
->getFuture(KeySpace::HgCommitToTreeFamily, commitID.getBytes())
|
||||
.then(
|
||||
.thenValue(
|
||||
[this,
|
||||
commitID](StoreResult result) -> folly::Future<unique_ptr<Tree>> {
|
||||
if (!result.isValid()) {
|
||||
@ -197,7 +197,7 @@ folly::Future<unique_ptr<Tree>> HgBackingStore::getTreeForCommitImpl(
|
||||
<< " for mercurial commit " << commitID.toString();
|
||||
|
||||
return localStore_->getTree(rootTreeHash)
|
||||
.then(
|
||||
.thenValue(
|
||||
[this, rootTreeHash, commitID](std::unique_ptr<Tree> tree)
|
||||
-> folly::Future<unique_ptr<Tree>> {
|
||||
if (tree) {
|
||||
|
Loading…
Reference in New Issue
Block a user