summaryrefslogtreecommitdiff
path: root/src/mongo/util/future.h
diff options
context:
space:
mode:
authorJason Carey <jcarey@argv.me>2018-03-21 00:15:35 -0400
committerJason Carey <jcarey@argv.me>2018-04-27 19:49:28 -0400
commit4ddf18bcf4d517c3dc0f005f9222ffaab9a86ffa (patch)
tree438865c1065d0a96c427b1ed3a89e5163d85699a /src/mongo/util/future.h
parent91eaa878c4feeebd9397c49180631fc719238aaf (diff)
downloadmongo-4ddf18bcf4d517c3dc0f005f9222ffaab9a86ffa.tar.gz
SERVER-34739 Migrate to 1 connpool in ARS
Migrate to 1 connection pool in mongos. This change involves the introduction of a transport layer baton, which improves perf for a particular transport layer when doing local scatter/gather operations.
Diffstat (limited to 'src/mongo/util/future.h')
-rw-r--r--src/mongo/util/future.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/mongo/util/future.h b/src/mongo/util/future.h
index 2485b170463..2b4d2c9c4f4 100644
--- a/src/mongo/util/future.h
+++ b/src/mongo/util/future.h
@@ -537,6 +537,11 @@ public:
setImpl([&] { sharedState->setError(std::move(status)); });
}
+ // TODO rename to not XXXWith and handle void
+ void setFromStatusWith(StatusWith<T> sw) noexcept {
+ setImpl([&] { sharedState->setFromStatusWith(std::move(sw)); });
+ }
+
/**
* Get a copyable SharedPromise that can be used to complete this Promise's Future.
*
@@ -1008,6 +1013,15 @@ public:
[](Func && func, const Status& status) noexcept { call(func, status); });
}
+ /**
+ * Ignores the return value of a future, transforming it down into a Future<void>.
+ *
+ * This only ignores values, not errors. Those remain propogated until an onError handler.
+ *
+ * Equivalent to then([](auto&&){});
+ */
+ Future<void> ignoreValue() && noexcept;
+
private:
template <typename T2>
friend class Future;
@@ -1203,6 +1217,10 @@ public:
return std::move(inner).tapAll(std::forward<Func>(func));
}
+ Future<void> ignoreValue() && noexcept {
+ return std::move(*this);
+ }
+
private:
template <typename T>
friend class Future;
@@ -1225,6 +1243,11 @@ private:
Future<FakeVoid> inner;
};
+template <typename T>
+ Future<void> Future<T>::ignoreValue() && noexcept {
+ return std::move(*this).then([](auto&&) {});
+}
+
/**
* Makes a ready Future with the return value of a nullary function. This has the same semantics as
* Promise::setWith, and has the same reasons to prefer it over Future<T>::makeReady(). Also, it