diff --git a/src/net/src/dispatch_thread.cc b/src/net/src/dispatch_thread.cc index 922688c178..647d254d10 100644 --- a/src/net/src/dispatch_thread.cc +++ b/src/net/src/dispatch_thread.cc @@ -64,10 +64,10 @@ int DispatchThread::StartThread() { } // Adding timer tasks and run timertaskThread - timerTaskThread_.AddTimerTask("blrpop_blocking_info_scan", 250, true, + timer_task_thread_.AddTimerTask("blrpop_blocking_info_scan", 250, true, [this] { this->ScanExpiredBlockedConnsOfBlrpop(); }); - timerTaskThread_.set_thread_name("TimerTaskThread"); - timerTaskThread_.StartThread(); + timer_task_thread_.set_thread_name("TimerTaskThread"); + timer_task_thread_.StartThread(); return ServerThread::StartThread(); } @@ -88,7 +88,7 @@ int DispatchThread::StopThread() { worker_thread_[i]->private_data_ = nullptr; } } - timerTaskThread_.StopThread(); + timer_task_thread_.StopThread(); return ServerThread::StopThread(); } diff --git a/src/net/src/dispatch_thread.h b/src/net/src/dispatch_thread.h index 0fb1b5c89c..6d6543d3a9 100644 --- a/src/net/src/dispatch_thread.h +++ b/src/net/src/dispatch_thread.h @@ -161,7 +161,7 @@ class DispatchThread : public ServerThread { */ std::shared_mutex block_mtx_; - TimerTaskThread timerTaskThread_; + TimerTaskThread timer_task_thread_; }; // class DispatchThread } // namespace net diff --git a/src/net/src/net_util.h b/src/net/src/net_util.h index fe96e0a950..7b8cd364f3 100644 --- a/src/net/src/net_util.h +++ b/src/net/src/net_util.h @@ -47,6 +47,12 @@ struct ExecTsWithId { } }; +/* + * For simplicity, current version of TimerTaskThread has no lock inside and all task should be registered before TimerTaskThread started, + * but if you have the needs of dynamically add/remove timer task after TimerTaskThread started, you can simply add a mutex to protect + * the timer_task_manager_ and also a pipe to wake up the maybe being endless-wait epoll(if all task consumed, epoll will sink into + * endless wait) to implement the feature. + */ class TimerTaskManager { public: TimerTaskManager() = default;