Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revised TimerTaskManager and add some comments #2776

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/net/src/dispatch_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -88,7 +88,7 @@ int DispatchThread::StopThread() {
worker_thread_[i]->private_data_ = nullptr;
}
}
timerTaskThread_.StopThread();
timer_task_thread_.StopThread();
return ServerThread::StopThread();
}

Expand Down
2 changes: 1 addition & 1 deletion src/net/src/dispatch_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class DispatchThread : public ServerThread {
*/
std::shared_mutex block_mtx_;

TimerTaskThread timerTaskThread_;
TimerTaskThread timer_task_thread_;
}; // class DispatchThread

} // namespace net
Expand Down
6 changes: 6 additions & 0 deletions src/net/src/net_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading