diff options
author | Mathias Stearn <mathias@10gen.com> | 2018-05-25 13:05:10 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2018-05-25 18:46:13 -0400 |
commit | f0e5229b631668c9bde511e607bf52fd871e582d (patch) | |
tree | 0141e574f53dab6361a69ce8bf0944c88fa381c6 /src/mongo/transport/baton.h | |
parent | fa9d7223cf59ee1b5681ea129fe86f55c608c632 (diff) | |
download | mongo-f0e5229b631668c9bde511e607bf52fd871e582d.tar.gz |
SERVER-35234 makePromiseFuture<T>()
Diffstat (limited to 'src/mongo/transport/baton.h')
-rw-r--r-- | src/mongo/transport/baton.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/mongo/transport/baton.h b/src/mongo/transport/baton.h index 59c2d7c06ab..65a9efbb7d8 100644 --- a/src/mongo/transport/baton.h +++ b/src/mongo/transport/baton.h @@ -70,14 +70,13 @@ public: */ template <typename Callback> Future<FutureContinuationResult<Callback>> execute(Callback&& cb) { - Promise<FutureContinuationResult<Callback>> promise; - auto future = promise.getFuture(); + auto pf = makePromiseFuture<FutureContinuationResult<Callback>>(); - schedule([ cb = std::forward<Callback>(cb), sp = promise.share() ]() mutable { + schedule([ cb = std::forward<Callback>(cb), sp = pf.promise.share() ]() mutable { sp.setWith(std::move(cb)); }); - return future; + return std::move(pf.future); } /** |