Rename chains to chain_ids in NetQuery.

This commit is contained in:
levlam 2022-02-03 22:32:47 +03:00
parent 0b33522821
commit 649f2b85f5
7 changed files with 27 additions and 26 deletions

View File

@ -1850,7 +1850,7 @@ class ToggleDialogIsBlockedActor final : public NetActorOnce {
CHECK(input_peer != nullptr && input_peer->get_id() != telegram_api::inputPeerEmpty::ID);
auto query = is_blocked ? G()->net_query_creator().create(telegram_api::contacts_block(std::move(input_peer)))
: G()->net_query_creator().create(telegram_api::contacts_unblock(std::move(input_peer)));
query->set_chains({sequence_dispatcher_id});
query->set_chain_ids({sequence_dispatcher_id});
send_query(std::move(query));
}

View File

@ -210,7 +210,7 @@ class StopPollActor final : public NetActorOnce {
std::move(input_reply_markup), vector<tl_object_ptr<telegram_api::MessageEntity>>(), 0));
if (!td_->auth_manager_->is_bot()) {
auto sequence_id = static_cast<uint64>(-1);
query->set_chains({sequence_id});
query->set_chain_ids({sequence_id});
}
send_query(std::move(query));
}

View File

@ -250,11 +250,11 @@ void SequenceDispatcher::close_silent() {
void MultiSequenceDispatcherOld::send(NetQueryPtr query) {
auto callback = query->move_callback();
CHECK(!callback.empty());
auto chains = query->chains();
auto chain_ids = query->get_chain_ids();
query->set_in_sequence_dispatcher(true);
CHECK(all_of(chains, [](auto chain_id) { return chain_id != 0; }));
CHECK(!chains.empty());
auto sequence_id = chains[0];
CHECK(all_of(chain_ids, [](auto chain_id) { return chain_id != 0; }));
CHECK(!chain_ids.empty());
auto sequence_id = chain_ids[0];
auto it_ok = dispatchers_.emplace(sequence_id, Data{0, ActorOwn<SequenceDispatcher>()});
auto &data = it_ok.first->second;
@ -287,15 +287,15 @@ class MultiSequenceDispatcherImpl final : public MultiSequenceDispatcher {
void send(NetQueryPtr query) final {
auto callback = query->move_callback();
CHECK(!callback.empty());
auto chains = query->chains();
auto chain_ids = query->get_chain_ids();
query->set_in_sequence_dispatcher(true);
CHECK(all_of(chains, [](auto chain_id) { return chain_id != 0; }));
CHECK(all_of(chain_ids, [](auto chain_id) { return chain_id != 0; }));
Node node;
node.net_query = std::move(query);
node.net_query->debug("Waiting at SequenceDispatcher");
node.net_query_ref = node.net_query.get_weak();
node.callback = std::move(callback);
scheduler_.create_task(chains, std::move(node));
scheduler_.create_task(chain_ids, std::move(node));
loop();
}

View File

@ -204,8 +204,8 @@ class NetQuery final : public TsListNode<NetQueryDebug> {
invoke_after_ = std::move(refs);
}
uint32 session_rand() const {
if (in_sequence_dispacher_ && !chains_.empty()) {
return static_cast<uint32>(chains_[0] >> 10);
if (in_sequence_dispacher_ && !chain_ids_.empty()) {
return static_cast<uint32>(chain_ids_[0] >> 10);
}
return 0;
}
@ -276,14 +276,15 @@ class NetQuery final : public TsListNode<NetQueryDebug> {
priority_ = priority;
}
Span<uint64> chains() const {
return chains_;
Span<uint64> get_chain_ids() const {
return chain_ids_;
}
void set_chains(std::vector<uint64> chains) {
chains_ = std::move(chains);
void set_chain_ids(vector<uint64> &&chain_ids) {
chain_ids_ = std::move(chain_ids);
}
void set_in_sequence_dispatcher(bool flag) {
in_sequence_dispacher_ = flag;
void set_in_sequence_dispatcher(bool in_sequence_dispacher) {
in_sequence_dispacher_ = in_sequence_dispacher;
}
bool in_sequence_dispatcher() const {
return in_sequence_dispacher_;
@ -303,8 +304,8 @@ class NetQuery final : public TsListNode<NetQueryDebug> {
BufferSlice answer_;
int32 tl_constructor_ = 0;
std::vector<NetQueryRef> invoke_after_;
std::vector<uint64> chains_;
vector<NetQueryRef> invoke_after_;
vector<uint64> chain_ids_;
bool in_sequence_dispacher_ = false;
bool may_be_lost_ = false;

View File

@ -25,12 +25,12 @@ NetQueryCreator::NetQueryCreator(std::shared_ptr<NetQueryStats> net_query_stats)
object_pool_.set_check_empty(true);
}
NetQueryPtr NetQueryCreator::create(const telegram_api::Function &function, std::vector<uint64> chains, DcId dc_id,
NetQueryPtr NetQueryCreator::create(const telegram_api::Function &function, vector<uint64> chain_ids, DcId dc_id,
NetQuery::Type type) {
return create(UniqueId::next(), function, std::move(chains), dc_id, type, NetQuery::AuthFlag::On);
return create(UniqueId::next(), function, std::move(chain_ids), dc_id, type, NetQuery::AuthFlag::On);
}
NetQueryPtr NetQueryCreator::create(uint64 id, const telegram_api::Function &function, std::vector<uint64> chains,
NetQueryPtr NetQueryCreator::create(uint64 id, const telegram_api::Function &function, vector<uint64> &&chain_ids,
DcId dc_id, NetQuery::Type type, NetQuery::AuthFlag auth_flag) {
LOG(INFO) << "Create query " << to_string(function);
auto storer = DefaultStorer<telegram_api::Function>(function);
@ -79,7 +79,7 @@ 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());
query->set_cancellation_token(query.generation());
query->set_chains(std::move(chains));
query->set_chain_ids(std::move(chain_ids));
return query;
}

View File

@ -29,14 +29,14 @@ class NetQueryCreator {
object_pool_.set_check_empty(false);
}
NetQueryPtr create(const telegram_api::Function &function, std::vector<uint64> chains = {}, DcId dc_id = DcId::main(),
NetQueryPtr create(const telegram_api::Function &function, vector<uint64> chain_ids = {}, DcId dc_id = DcId::main(),
NetQuery::Type type = NetQuery::Type::Common);
NetQueryPtr create_unauth(const telegram_api::Function &function, DcId dc_id = DcId::main()) {
return create(UniqueId::next(), function, {}, dc_id, NetQuery::Type::Common, NetQuery::AuthFlag::Off);
}
NetQueryPtr create(uint64 id, const telegram_api::Function &function, std::vector<uint64> chains, DcId dc_id,
NetQueryPtr create(uint64 id, const telegram_api::Function &function, vector<uint64> &&chain_ids, DcId dc_id,
NetQuery::Type type, NetQuery::AuthFlag auth_flag);
private:

View File

@ -59,7 +59,7 @@ void NetQueryDispatcher::dispatch(NetQueryPtr net_query) {
return complete_net_query(std::move(net_query));
}
if (!net_query->in_sequence_dispatcher() && !net_query->chains().empty()) {
if (!net_query->in_sequence_dispatcher() && !net_query->get_chain_ids().empty()) {
net_query->debug("sent to main sequence dispatcher");
send_closure(sequence_dispatcher_, &MultiSequenceDispatcher::send, std::move(net_query));
return;