From a6cb25204df7a7e23678a6bd9b2e28e5e36dc9d9 Mon Sep 17 00:00:00 2001 From: lichunjun Date: Fri, 3 Feb 2023 20:17:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(eventx):=20=E5=9C=A8ThreadLoop::threadProc?= =?UTF-8?q?()=E6=89=A7=E8=A1=8C=E4=BB=BB=E5=8A=A1=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E5=8A=A0try...catch=E5=BC=82=E5=B8=B8=E6=8D=95?= =?UTF-8?q?=E8=8E=B7=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/eventx/thread_pool.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/eventx/thread_pool.cpp b/modules/eventx/thread_pool.cpp index 1bf59fe..2e3747f 100644 --- a/modules/eventx/thread_pool.cpp +++ b/modules/eventx/thread_pool.cpp @@ -291,8 +291,15 @@ void ThreadPool::threadProc(ThreadToken thread_token) auto exec_time_point = Clock::now(); auto wait_time_cost = exec_time_point - item->create_time_point; - if (item->backend_task) - item->backend_task(); + if (item->backend_task) { + try { + item->backend_task(); + } catch (const std::exception &e) { + LogErr("catch execption: %s", e.what()); + } catch (...) { + LogErr("catch unknown execption"); + } + } auto exec_time_cost = Clock::now() - exec_time_point; -- Gitee