Simplify NetQuery creation.
This commit is contained in:
parent
62eaa0b5a9
commit
eb06c93532
@ -34,10 +34,9 @@ void NetQuery::debug(string state, bool may_be_lost) {
|
||||
}
|
||||
}
|
||||
|
||||
NetQuery::NetQuery(State state, uint64 id, BufferSlice &&query, BufferSlice &&answer, DcId dc_id, Type type,
|
||||
AuthFlag auth_flag, GzipFlag gzip_flag, int32 tl_constructor, int32 total_timeout_limit,
|
||||
NetQueryStats *stats, vector<ChainId> chain_ids)
|
||||
: state_(state)
|
||||
NetQuery::NetQuery(uint64 id, BufferSlice &&query, DcId dc_id, Type type, AuthFlag auth_flag, GzipFlag gzip_flag,
|
||||
int32 tl_constructor, int32 total_timeout_limit, NetQueryStats *stats, vector<ChainId> chain_ids)
|
||||
: state_(State::Query)
|
||||
, type_(type)
|
||||
, auth_flag_(auth_flag)
|
||||
, gzip_flag_(gzip_flag)
|
||||
@ -45,7 +44,6 @@ NetQuery::NetQuery(State state, uint64 id, BufferSlice &&query, BufferSlice &&an
|
||||
, status_()
|
||||
, id_(id)
|
||||
, query_(std::move(query))
|
||||
, answer_(std::move(answer))
|
||||
, tl_constructor_(tl_constructor)
|
||||
, total_timeout_limit_(total_timeout_limit) {
|
||||
CHECK(id_ != 0);
|
||||
|
@ -46,10 +46,11 @@ class NetQueryCallback : public Actor {
|
||||
};
|
||||
|
||||
class NetQuery final : public TsListNode<NetQueryDebug> {
|
||||
enum class State : int8 { Empty, Query, OK, Error };
|
||||
|
||||
public:
|
||||
NetQuery() = default;
|
||||
|
||||
enum class State : int8 { Empty, Query, OK, Error };
|
||||
enum class Type : int8 { Common, Upload, Download, DownloadSmall };
|
||||
enum class AuthFlag : int8 { Off, On };
|
||||
enum class GzipFlag : int8 { Off, On };
|
||||
@ -343,9 +344,8 @@ class NetQuery final : public TsListNode<NetQueryDebug> {
|
||||
Promise<> quick_ack_promise_; // for Session and to be set by caller
|
||||
bool need_resend_on_503_ = true; // for NetQueryDispatcher and to be set by caller
|
||||
|
||||
NetQuery(State state, uint64 id, BufferSlice &&query, BufferSlice &&answer, DcId dc_id, Type type, AuthFlag auth_flag,
|
||||
GzipFlag gzip_flag, int32 tl_constructor, int32 total_timeout_limit, NetQueryStats *stats,
|
||||
vector<ChainId> chain_ids);
|
||||
NetQuery(uint64 id, BufferSlice &&query, DcId dc_id, Type type, AuthFlag auth_flag, GzipFlag gzip_flag,
|
||||
int32 tl_constructor, int32 total_timeout_limit, NetQueryStats *stats, vector<ChainId> chain_ids);
|
||||
};
|
||||
|
||||
inline StringBuilder &operator<<(StringBuilder &stream, const NetQuery &net_query) {
|
||||
|
@ -81,9 +81,8 @@ NetQueryPtr NetQueryCreator::create(uint64 id, const telegram_api::Function &fun
|
||||
}
|
||||
}
|
||||
|
||||
auto query =
|
||||
object_pool_.create(NetQuery::State::Query, id, std::move(slice), BufferSlice(), dc_id, type, auth_flag,
|
||||
gzip_flag, tl_constructor, total_timeout_limit, net_query_stats_.get(), std::move(chain_ids));
|
||||
auto query = object_pool_.create(id, std::move(slice), dc_id, type, auth_flag, gzip_flag, tl_constructor,
|
||||
total_timeout_limit, net_query_stats_.get(), std::move(chain_ids));
|
||||
query->set_cancellation_token(query.generation());
|
||||
return query;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user