Move get_database_scheduler_id to Global.

This commit is contained in:
levlam 2023-07-26 13:05:34 +03:00
parent e8d92b0dcb
commit 06731d965d
4 changed files with 11 additions and 11 deletions

View File

@ -86,8 +86,11 @@ struct ServerTimeDiff {
};
Status Global::init(ActorId<Td> td, unique_ptr<TdDb> td_db_ptr) {
gc_scheduler_id_ = min(Scheduler::instance()->sched_id() + 2, Scheduler::instance()->sched_count() - 1);
slow_net_scheduler_id_ = min(Scheduler::instance()->sched_id() + 3, Scheduler::instance()->sched_count() - 1);
auto current_scheduler_id = Scheduler::instance()->sched_id();
auto max_scheduler_id = Scheduler::instance()->sched_count() - 1;
database_scheduler_id_ = min(current_scheduler_id + 1, max_scheduler_id);
gc_scheduler_id_ = min(current_scheduler_id + 2, max_scheduler_id);
slow_net_scheduler_id_ = min(current_scheduler_id + 3, max_scheduler_id);
td_ = td;
td_db_ = std::move(td_db_ptr);

View File

@ -418,6 +418,10 @@ class Global final : public ActorContext {
return use_file_database();
}
int32 get_database_scheduler_id() {
return database_scheduler_id_;
}
int32 get_gc_scheduler_id() const {
return gc_scheduler_id_;
}
@ -542,6 +546,7 @@ class Global final : public ActorContext {
OptionManager *option_manager_ = nullptr;
int32 database_scheduler_id_ = 0;
int32 gc_scheduler_id_ = 0;
int32 slow_net_scheduler_id_ = 0;

View File

@ -2985,7 +2985,7 @@ void Td::run_request(uint64 id, tl_object_ptr<td_api::Function> function) {
Result<TdDb::OpenedDatabase> r_opened_database) mutable {
send_closure(actor_id, &Td::init, std::move(parameters), std::move(r_opened_database));
});
return TdDb::open(get_database_scheduler_id(), std::move(parameters.second), std::move(promise));
return TdDb::open(G()->get_database_scheduler_id(), std::move(parameters.second), std::move(promise));
}
default:
if (is_preinitialization_request(function_id)) {
@ -3549,12 +3549,6 @@ void Td::complete_pending_preauthentication_requests(const T &func) {
}
}
int32 Td::get_database_scheduler_id() {
auto current_scheduler_id = Scheduler::instance()->sched_id();
auto scheduler_count = Scheduler::instance()->sched_count();
return min(current_scheduler_id + 1, scheduler_count - 1);
}
void Td::finish_set_parameters() {
CHECK(set_parameters_request_id_ != 0);
set_parameters_request_id_ = 0;

View File

@ -1692,8 +1692,6 @@ class Td final : public Actor {
static DbKey as_db_key(string key);
static int32 get_database_scheduler_id();
struct Parameters {
int32 api_id_ = 0;
string api_hash_;