mirror of
https://github.com/PaiGramTeam/telegram-bot-api.git
synced 2024-11-26 10:16:29 +00:00
Update CPU statistics on a dedicated thread.
This commit is contained in:
parent
1cab23c1f1
commit
18b5f287f7
@ -93,9 +93,14 @@ struct SharedData {
|
|||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
static td::int32 get_thread_count() {
|
static td::int32 get_statistics_thread_id() {
|
||||||
|
// the thread for CPU usage updating
|
||||||
return 11;
|
return 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static td::int32 get_thread_count() {
|
||||||
|
return 12;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ClientParameters {
|
struct ClientParameters {
|
||||||
|
@ -556,7 +556,9 @@ int main(int argc, char *argv[]) {
|
|||||||
next_cron_time = now;
|
next_cron_time = now;
|
||||||
}
|
}
|
||||||
next_cron_time += 1.0;
|
next_cron_time += 1.0;
|
||||||
ServerCpuStat::update(now);
|
auto guard = sched.get_main_guard();
|
||||||
|
td::Scheduler::instance()->run_on_scheduler(SharedData::get_statistics_thread_id(),
|
||||||
|
[](td::Unit) { ServerCpuStat::update(td::Time::now()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now >= start_time + 600) {
|
if (now >= start_time + 600) {
|
||||||
|
Loading…
Reference in New Issue
Block a user