From 925f11416a39780faaddcda591af5224367330db Mon Sep 17 00:00:00 2001 From: azw Date: Sun, 9 Apr 2023 08:03:10 +0000 Subject: [PATCH] 1 --- server/wsproxy/app.cc | 59 ++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/server/wsproxy/app.cc b/server/wsproxy/app.cc index 5b7bb12..7d5f93b 100644 --- a/server/wsproxy/app.cc +++ b/server/wsproxy/app.cc @@ -122,40 +122,34 @@ bool App::Init(int argc, char* argv[]) if (getenv("is_dev_env")) { perf_log_time = 1000 * 10; } - #if 0 - f8::Timer::Instance()->AddRepeatTimer(perf_log_time, - a8::XParams(), - [] (const a8::XParams& param) - { - SavePerfLog(); - }); - #endif + f8::Timer::Instance()->SetInterval + (perf_log_time, + [] (int event, const a8::Args* args) + { + SavePerfLog(); + }); } if (HasFlag(1)) { - #if 0 - f8::Timer::Instance()->AddDeadLineTimer( - 1000 * 60, - a8::XParams(), - [] (const a8::XParams& param) - { - App::Instance()->terminated = true; - App::Instance()->NotifyLoopCond(); - } - ); - #endif + f8::Timer::Instance()->SetTimeout + ( + 1000 * 60, + [] (int event, const a8::Args* args) + { + App::Instance()->terminated = true; + App::Instance()->NotifyLoopCond(); + } + ); } if (HasFlag(4)) { - #if 0 - a8::Timer::Instance()->AddDeadLineTimer( - 1000 * 30, - a8::XParams(), - [] (const a8::XParams& param) - { - App::Instance()->shutdowned = true; - a8::XPrintf("shutdowned\n", {}); - } - ); - #endif + f8::Timer::Instance()->SetTimeout + ( + 1000 * 30, + [] (int event, const a8::Args* args) + { + App::Instance()->shutdowned = true; + a8::XPrintf("shutdowned\n", {}); + } + ); } return true; } @@ -253,7 +247,10 @@ void App::Schedule() { std::unique_lock lk(*loop_mutex_); if (!HasTask()) { - #if 0 + #if 1 + int sleep_time = 1; + loop_cond_->wait_for(lk, std::chrono::milliseconds(sleep_time)); + #else int sleep_time = f8::Timer::Instance()->GetIdleableMillSeconds(); loop_cond_->wait_for(lk, std::chrono::milliseconds(sleep_time)); if (sleep_time > perf.max_timer_idle) {