Skip to content

Commit 9d85318

Browse files
committed
opt(eventx):1.10.16, 在LoopWDog加trace监控与超时警告
1 parent 38d15ec commit 9d85318

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

modules/eventx/loop_wdog.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ LoopWDog::LoopBlockCallback _loop_die_cb = OnLoopBlock; //! 回调函数
6969
LoopWDog::LoopBlockCallback _loop_recover_cb = OnLoopRecover; //! 回调函数
7070

7171
void SendLoopFunc() {
72+
RECORD_SCOPE();
7273
std::lock_guard<std::mutex> lg(_mutex_lock);
7374
for (auto loop_info_sptr : _loop_info_vec) {
7475
if (loop_info_sptr->loop->isRunning()) {
7576
if (loop_info_sptr->state == State::kChecked) {
7677
loop_info_sptr->state = State::kTobeCheck;
78+
79+
auto start_ts = std::chrono::steady_clock::now();
80+
7781
loop_info_sptr->loop->runInLoop(
7882
[loop_info_sptr] {
7983
if (loop_info_sptr->state == State::kTimeout)
@@ -82,6 +86,11 @@ void SendLoopFunc() {
8286
},
8387
"LoopWdog"
8488
);
89+
90+
auto time_cost = std::chrono::steady_clock::now() - start_ts;
91+
if (time_cost > std::chrono::milliseconds(100)) {
92+
LogWarn("loop \"%s\" runInLoop() cost > 100 ms, %lu us", loop_info_sptr->name.c_str(), time_cost.count() / 1000);
93+
}
8594
}
8695
}
8796
}

version.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
# TBOX版本号
2222
TBOX_VERSION_MAJOR := 1
2323
TBOX_VERSION_MINOR := 10
24-
TBOX_VERSION_REVISION := 15
24+
TBOX_VERSION_REVISION := 16

0 commit comments

Comments
 (0)