mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-09-01 20:16:01 +02:00
Use Scheduler::run_on_scheduler.
This commit is contained in:
parent
95131fe376
commit
0749acb7e6
@ -4856,30 +4856,13 @@ void Client::on_closed() {
|
|||||||
if (logging_out_) {
|
if (logging_out_) {
|
||||||
parameters_->shared_data_->webhook_db_->erase(bot_token_with_dc_);
|
parameters_->shared_data_->webhook_db_->erase(bot_token_with_dc_);
|
||||||
|
|
||||||
class RmWorker final : public td::Actor {
|
td::Scheduler::instance()->run_on_scheduler(get_database_scheduler_id(),
|
||||||
public:
|
[actor_id = actor_id(this), dir = dir_](td::Unit) {
|
||||||
RmWorker(td::string dir, td::ActorId<Client> parent) : dir_(std::move(dir)), parent_(std::move(parent)) {
|
CHECK(dir.size() >= 24);
|
||||||
}
|
CHECK(dir.back() == TD_DIR_SLASH);
|
||||||
|
td::rmrf(dir).ignore();
|
||||||
private:
|
send_closure(actor_id, &Client::finish_closing);
|
||||||
td::string dir_;
|
});
|
||||||
td::ActorId<Client> parent_;
|
|
||||||
|
|
||||||
void start_up() final {
|
|
||||||
CHECK(dir_.size() >= 24);
|
|
||||||
CHECK(dir_.back() == TD_DIR_SLASH);
|
|
||||||
td::rmrf(dir_).ignore();
|
|
||||||
stop();
|
|
||||||
}
|
|
||||||
void tear_down() final {
|
|
||||||
send_closure(parent_, &Client::finish_closing);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// NB: 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();
|
|
||||||
auto scheduler_id = td::min(current_scheduler_id + 1, scheduler_count - 1);
|
|
||||||
td::create_actor_on_scheduler<RmWorker>("RmWorker", scheduler_id, dir_, actor_id(this)).release();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4899,6 +4882,13 @@ void Client::timeout_expired() {
|
|||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td::int32 Client::get_database_scheduler_id() {
|
||||||
|
// NB: 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);
|
||||||
|
}
|
||||||
|
|
||||||
void Client::clear_tqueue() {
|
void Client::clear_tqueue() {
|
||||||
CHECK(webhook_id_.empty());
|
CHECK(webhook_id_.empty());
|
||||||
auto &tqueue = parameters_->shared_data_->tqueue_;
|
auto &tqueue = parameters_->shared_data_->tqueue_;
|
||||||
|
@ -302,6 +302,8 @@ class Client final : public WebhookActor::Callback {
|
|||||||
void on_closed();
|
void on_closed();
|
||||||
void finish_closing();
|
void finish_closing();
|
||||||
|
|
||||||
|
static int32 get_database_scheduler_id();
|
||||||
|
|
||||||
void clear_tqueue();
|
void clear_tqueue();
|
||||||
|
|
||||||
bool allow_update_before_authorization(const td_api::Object *update) const;
|
bool allow_update_before_authorization(const td_api::Object *update) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user