Move promise_send_closure to PromiseFuture.h.
This commit is contained in:
parent
340fb779c3
commit
ebebe0300c
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -51,6 +51,14 @@ class EventPromise final : public PromiseInterface<Unit> {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class SendClosure {
|
||||
public:
|
||||
template <class... ArgsT>
|
||||
void operator()(ArgsT &&...args) const {
|
||||
send_closure(std::forward<ArgsT>(args)...);
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
inline Promise<Unit> create_event_promise(EventFull &&ok) {
|
||||
@ -287,6 +295,13 @@ FutureActor<T> send_promise(ActorId<ActorAT> actor_id, ResultT (ActorBT::*func)(
|
||||
return pf.move_future();
|
||||
}
|
||||
|
||||
template <class... ArgsT>
|
||||
auto promise_send_closure(ArgsT &&...args) {
|
||||
return [t = std::make_tuple(std::forward<ArgsT>(args)...)](auto &&res) mutable {
|
||||
call_tuple(detail::SendClosure(), std::tuple_cat(std::move(t), std::make_tuple(std::forward<decltype(res)>(res))));
|
||||
};
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Promise<T> create_promise_from_promise_actor(PromiseActor<T> &&from) {
|
||||
return Promise<T>(td::make_unique<PromiseActor<T>>(std::move(from)));
|
||||
|
@ -323,32 +323,8 @@ class JoinPromise final : public PromiseInterface<Unit> {
|
||||
private:
|
||||
std::tuple<std::decay_t<ArgsT>...> promises_;
|
||||
};
|
||||
|
||||
class SendClosure {
|
||||
public:
|
||||
template <class... ArgsT>
|
||||
void operator()(ArgsT &&...args) const {
|
||||
send_closure(std::forward<ArgsT>(args)...);
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
//template <class T>
|
||||
//template <class... ArgsT>
|
||||
//auto Promise<T>::send_closure(ArgsT &&... args) {
|
||||
// return [promise = std::move(*this), t = std::make_tuple(std::forward<ArgsT>(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 <class... ArgsT>
|
||||
auto promise_send_closure(ArgsT &&...args) {
|
||||
return [t = std::make_tuple(std::forward<ArgsT>(args)...)](auto &&res) mutable {
|
||||
call_tuple(detail::SendClosure(), std::tuple_cat(std::move(t), std::make_tuple(std::forward<decltype(res)>(res))));
|
||||
};
|
||||
}
|
||||
|
||||
class PromiseCreator {
|
||||
public:
|
||||
template <class OkT, class ArgT = detail::drop_result_t<detail::get_arg_t<OkT>>>
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user