Make CountryInfoManager actor.
GitOrigin-RevId: 4e03cee13e38b682c6e063f16cd078345c0c00ff
This commit is contained in:
parent
1c6f778e8d
commit
eff3dd9f36
@ -44,7 +44,11 @@ class GetNearestDcQuery : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
CountryInfoManager::CountryInfoManager(Td *td) : td_(td) {
|
||||
CountryInfoManager::CountryInfoManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
|
||||
}
|
||||
|
||||
void CountryInfoManager::tear_down() {
|
||||
parent_.reset();
|
||||
}
|
||||
|
||||
void CountryInfoManager::get_current_country_code(Promise<string> &&promise) {
|
||||
|
@ -6,6 +6,7 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/actor/actor.h"
|
||||
#include "td/actor/PromiseFuture.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
@ -14,14 +15,17 @@ namespace td {
|
||||
|
||||
class Td;
|
||||
|
||||
class CountryInfoManager {
|
||||
class CountryInfoManager : public Actor {
|
||||
public:
|
||||
explicit CountryInfoManager(Td *td);
|
||||
explicit CountryInfoManager(Td *td, ActorShared<> parent);
|
||||
|
||||
void get_current_country_code(Promise<string> &&promise);
|
||||
|
||||
private:
|
||||
void tear_down() override;
|
||||
|
||||
Td *td_;
|
||||
ActorShared<> parent_;
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
|
@ -3770,6 +3770,7 @@ void Td::inc_actor_refcnt() {
|
||||
|
||||
void Td::dec_actor_refcnt() {
|
||||
actor_refcnt_--;
|
||||
LOG(DEBUG) << "Decrease reference count to " << actor_refcnt_;
|
||||
if (actor_refcnt_ == 0) {
|
||||
if (close_flag_ == 2) {
|
||||
create_reference();
|
||||
@ -3858,6 +3859,7 @@ void Td::inc_request_actor_refcnt() {
|
||||
|
||||
void Td::dec_request_actor_refcnt() {
|
||||
request_actor_refcnt_--;
|
||||
LOG(DEBUG) << "Decrease request actor count to " << request_actor_refcnt_;
|
||||
if (request_actor_refcnt_ == 0) {
|
||||
LOG(WARNING) << "Have no request actors";
|
||||
clear();
|
||||
@ -3974,6 +3976,8 @@ void Td::clear() {
|
||||
LOG(DEBUG) << "BackgroundManager actor was cleared" << timer;
|
||||
contacts_manager_actor_.reset();
|
||||
LOG(DEBUG) << "ContactsManager actor was cleared" << timer;
|
||||
country_info_manager_actor_.reset();
|
||||
LOG(DEBUG) << "CountryInfoManager actor was cleared" << timer;
|
||||
file_manager_actor_.reset();
|
||||
LOG(DEBUG) << "FileManager actor was cleared" << timer;
|
||||
file_reference_manager_actor_.reset();
|
||||
@ -4395,7 +4399,6 @@ void Td::init_managers() {
|
||||
VLOG(td_init) << "Create Managers";
|
||||
audios_manager_ = make_unique<AudiosManager>(this);
|
||||
callback_queries_manager_ = make_unique<CallbackQueriesManager>(this);
|
||||
country_info_manager_ = make_unique<CountryInfoManager>(this);
|
||||
documents_manager_ = make_unique<DocumentsManager>(this);
|
||||
video_notes_manager_ = make_unique<VideoNotesManager>(this);
|
||||
videos_manager_ = make_unique<VideosManager>(this);
|
||||
@ -4410,6 +4413,8 @@ void Td::init_managers() {
|
||||
contacts_manager_ = make_unique<ContactsManager>(this, create_reference());
|
||||
contacts_manager_actor_ = register_actor("ContactsManager", contacts_manager_.get());
|
||||
G()->set_contacts_manager(contacts_manager_actor_.get());
|
||||
country_info_manager_ = make_unique<CountryInfoManager>(this, create_reference());
|
||||
country_info_manager_actor_ = register_actor("CountryInfoManager", country_info_manager_.get());
|
||||
inline_queries_manager_ = make_unique<InlineQueriesManager>(this, create_reference());
|
||||
inline_queries_manager_actor_ = register_actor("InlineQueriesManager", inline_queries_manager_.get());
|
||||
messages_manager_ = make_unique<MessagesManager>(this, create_reference());
|
||||
|
@ -137,7 +137,6 @@ class Td final : public NetQueryCallback {
|
||||
|
||||
unique_ptr<AudiosManager> audios_manager_;
|
||||
unique_ptr<CallbackQueriesManager> callback_queries_manager_;
|
||||
unique_ptr<CountryInfoManager> country_info_manager_;
|
||||
unique_ptr<DocumentsManager> documents_manager_;
|
||||
unique_ptr<VideoNotesManager> video_notes_manager_;
|
||||
unique_ptr<VideosManager> videos_manager_;
|
||||
@ -151,6 +150,8 @@ class Td final : public NetQueryCallback {
|
||||
ActorOwn<BackgroundManager> background_manager_actor_;
|
||||
unique_ptr<ContactsManager> contacts_manager_;
|
||||
ActorOwn<ContactsManager> contacts_manager_actor_;
|
||||
unique_ptr<CountryInfoManager> country_info_manager_;
|
||||
ActorOwn<CountryInfoManager> country_info_manager_actor_;
|
||||
unique_ptr<FileManager> file_manager_;
|
||||
ActorOwn<FileManager> file_manager_actor_;
|
||||
unique_ptr<FileReferenceManager> file_reference_manager_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user