diff --git a/td/telegram/DownloadManager.cpp b/td/telegram/DownloadManager.cpp index 88c784dc2..9912610e0 100644 --- a/td/telegram/DownloadManager.cpp +++ b/td/telegram/DownloadManager.cpp @@ -15,6 +15,7 @@ #include "td/telegram/TdParameters.h" #include "td/actor/MultiPromise.h" +#include "td/actor/PromiseFuture.h" #include "td/utils/algorithm.h" #include "td/utils/FlatHashMap.h" diff --git a/td/telegram/SequenceDispatcher.cpp b/td/telegram/SequenceDispatcher.cpp index fb01bdb94..8f46379d2 100644 --- a/td/telegram/SequenceDispatcher.cpp +++ b/td/telegram/SequenceDispatcher.cpp @@ -10,6 +10,8 @@ #include "td/telegram/net/NetQueryDispatcher.h" #include "td/telegram/Td.h" +#include "td/actor/PromiseFuture.h" + #include "td/utils/algorithm.h" #include "td/utils/ChainScheduler.h" #include "td/utils/format.h" diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index 362adc812..9693bfb19 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -26,6 +26,8 @@ #include "td/mtproto/SessionConnection.h" #include "td/mtproto/TransportType.h" +#include "td/actor/PromiseFuture.h" + #include "td/utils/algorithm.h" #include "td/utils/as.h" #include "td/utils/format.h" diff --git a/tdactor/td/actor/PromiseFuture.h b/tdactor/td/actor/PromiseFuture.h index 1a8940558..d2585afc2 100644 --- a/tdactor/td/actor/PromiseFuture.h +++ b/tdactor/td/actor/PromiseFuture.h @@ -51,6 +51,14 @@ class EventPromise final : public PromiseInterface { } } }; + +class SendClosure { + public: + template + void operator()(ArgsT &&...args) const { + send_closure(std::forward(args)...); + } +}; } // namespace detail inline Promise create_event_promise(EventFull &&ok) { @@ -287,6 +295,13 @@ FutureActor send_promise(ActorId actor_id, ResultT (ActorBT::*func)( return pf.move_future(); } +template +auto promise_send_closure(ArgsT &&...args) { + return [t = std::make_tuple(std::forward(args)...)](auto &&res) mutable { + call_tuple(detail::SendClosure(), std::tuple_cat(std::move(t), std::make_tuple(std::forward(res)))); + }; +} + template Promise create_promise_from_promise_actor(PromiseActor &&from) { return Promise(td::make_unique>(std::move(from))); diff --git a/tdutils/td/utils/Promise.h b/tdutils/td/utils/Promise.h index 072c24f0e..252727da0 100644 --- a/tdutils/td/utils/Promise.h +++ b/tdutils/td/utils/Promise.h @@ -323,32 +323,8 @@ class JoinPromise final : public PromiseInterface { private: std::tuple...> promises_; }; - -class SendClosure { - public: - template - void operator()(ArgsT &&...args) const { - send_closure(std::forward(args)...); - } -}; } // namespace detail -//template -//template -//auto Promise::send_closure(ArgsT &&... args) { -// return [promise = std::move(*this), t = std::make_tuple(std::forward(args)...)](auto &&r_res) mutable { -// TRY_RESULT_PROMISE(promise, res, std::move(r_res)); -// call_tuple(detail::SendClosure(), std::tuple_cat(std::move(t), std::make_tuple(std::move(res), std::move(promise)))); -// }; -//} - -template -auto promise_send_closure(ArgsT &&...args) { - return [t = std::make_tuple(std::forward(args)...)](auto &&res) mutable { - call_tuple(detail::SendClosure(), std::tuple_cat(std::move(t), std::make_tuple(std::forward(res)))); - }; -} - class PromiseCreator { public: template >> diff --git a/test/online.cpp b/test/online.cpp index 50b87081e..db6832886 100644 --- a/test/online.cpp +++ b/test/online.cpp @@ -12,6 +12,7 @@ #include "td/actor/actor.h" #include "td/actor/ConcurrentScheduler.h" #include "td/actor/MultiPromise.h" +#include "td/actor/PromiseFuture.h" #include "td/utils/crypto.h" #include "td/utils/FileLog.h"