mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-12-23 19:25:54 +01:00
Update TDLib and destroy some big data storages asynchronously.
This commit is contained in:
parent
0bf71e15db
commit
2633de8b53
@ -185,6 +185,12 @@ Client::Client(td::ActorShared<> parent, const td::string &bot_token, bool is_te
|
||||
CHECK(is_inited);
|
||||
}
|
||||
|
||||
Client::~Client() {
|
||||
td::Scheduler::instance()->destroy_on_scheduler(get_file_gc_scheduler_id(), messages_, users_, groups_, supergroups_,
|
||||
chats_, reply_message_ids_, yet_unsent_reply_message_ids_,
|
||||
sticker_set_names_);
|
||||
}
|
||||
|
||||
bool Client::init_methods() {
|
||||
methods_.emplace("getme", &Client::process_get_me_query);
|
||||
methods_.emplace("getmycommands", &Client::process_get_my_commands_query);
|
||||
@ -4856,7 +4862,7 @@ void Client::on_closed() {
|
||||
if (logging_out_) {
|
||||
parameters_->shared_data_->webhook_db_->erase(bot_token_with_dc_);
|
||||
|
||||
td::Scheduler::instance()->run_on_scheduler(get_database_scheduler_id(),
|
||||
td::Scheduler::instance()->run_on_scheduler(get_file_gc_scheduler_id(),
|
||||
[actor_id = actor_id(this), dir = dir_](td::Unit) {
|
||||
CHECK(dir.size() >= 24);
|
||||
CHECK(dir.back() == TD_DIR_SLASH);
|
||||
@ -4883,12 +4889,19 @@ void Client::timeout_expired() {
|
||||
}
|
||||
|
||||
td::int32 Client::get_database_scheduler_id() {
|
||||
// NB: the same scheduler as for database in Td
|
||||
// the same scheduler as for database in Td
|
||||
auto current_scheduler_id = td::Scheduler::instance()->sched_id();
|
||||
auto scheduler_count = td::Scheduler::instance()->sched_count();
|
||||
return td::min(current_scheduler_id + 1, scheduler_count - 1);
|
||||
}
|
||||
|
||||
td::int32 Client::get_file_gc_scheduler_id() {
|
||||
// the same scheduler as for file GC in Td
|
||||
auto current_scheduler_id = td::Scheduler::instance()->sched_id();
|
||||
auto scheduler_count = td::Scheduler::instance()->sched_count();
|
||||
return td::min(current_scheduler_id + 2, scheduler_count - 1);
|
||||
}
|
||||
|
||||
void Client::clear_tqueue() {
|
||||
CHECK(webhook_id_.empty());
|
||||
auto &tqueue = parameters_->shared_data_->tqueue_;
|
||||
|
@ -42,6 +42,11 @@ class Client final : public WebhookActor::Callback {
|
||||
public:
|
||||
Client(td::ActorShared<> parent, const td::string &bot_token, bool is_test_dc, td::int64 tqueue_id,
|
||||
std::shared_ptr<const ClientParameters> parameters, td::ActorId<BotStatActor> stat_actor);
|
||||
Client(const Client &) = delete;
|
||||
Client &operator=(const Client &) = delete;
|
||||
Client(Client &&) = delete;
|
||||
Client &operator=(Client &&) = delete;
|
||||
~Client();
|
||||
|
||||
void send(PromisedQueryPtr query) final;
|
||||
|
||||
@ -304,6 +309,8 @@ class Client final : public WebhookActor::Callback {
|
||||
|
||||
static int32 get_database_scheduler_id();
|
||||
|
||||
static int32 get_file_gc_scheduler_id();
|
||||
|
||||
void clear_tqueue();
|
||||
|
||||
bool allow_update_before_authorization(const td_api::Object *update) const;
|
||||
|
Loading…
Reference in New Issue
Block a user