From ee4ef24cda5f72aea59b910e6bd976202ebfcd56 Mon Sep 17 00:00:00 2001 From: wangzhaoyong Date: Tue, 8 Jul 2025 21:20:22 +0800 Subject: [PATCH] add uv_thread_join MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: [Bug]: worker线程退出thread处理修复 https://gitee.com/openharmony/commonlibrary_ets_utils/issues/ICKUM1 Signed-off-by: wangzhaoyong Change-Id: I3a89c00e651fdca125c56d11173f84935b491705 --- js_concurrent_module/taskpool/task_runner.h | 5 ++++- js_concurrent_module/taskpool/thread.h | 2 +- js_concurrent_module/worker/thread.h | 2 +- js_concurrent_module/worker/worker_runner.h | 5 ++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/js_concurrent_module/taskpool/task_runner.h b/js_concurrent_module/taskpool/task_runner.h index dde93e15..9b864774 100644 --- a/js_concurrent_module/taskpool/task_runner.h +++ b/js_concurrent_module/taskpool/task_runner.h @@ -39,7 +39,10 @@ public: class TaskInnerRunner : public Thread { public: explicit TaskInnerRunner(const TaskRunner* runner); - ~TaskInnerRunner() = default; + ~TaskInnerRunner() { + uv_thread_join(&tid_); + } + void Run() override; private: diff --git a/js_concurrent_module/taskpool/thread.h b/js_concurrent_module/taskpool/thread.h index c261cb52..9d69768d 100644 --- a/js_concurrent_module/taskpool/thread.h +++ b/js_concurrent_module/taskpool/thread.h @@ -31,7 +31,7 @@ public: return tid_; } -private: +protected: uv_thread_t tid_ {0}; }; } // namespace Commonlibrary::Concurrent::TaskPoolModule diff --git a/js_concurrent_module/worker/thread.h b/js_concurrent_module/worker/thread.h index 3870a545..560245d4 100644 --- a/js_concurrent_module/worker/thread.h +++ b/js_concurrent_module/worker/thread.h @@ -31,7 +31,7 @@ public: return tId_; } -private: +protected: uv_thread_t tId_ {0}; }; } // namespace Commonlibrary::Concurrent::WorkerModule diff --git a/js_concurrent_module/worker/worker_runner.h b/js_concurrent_module/worker/worker_runner.h index c2ccc2c7..d139332e 100644 --- a/js_concurrent_module/worker/worker_runner.h +++ b/js_concurrent_module/worker/worker_runner.h @@ -39,7 +39,10 @@ public: class WorkerInnerRunner : public Thread { public: explicit WorkerInnerRunner(const WorkerRunner* runner); - ~WorkerInnerRunner() = default; + ~WorkerInnerRunner() { + uv_thread_join(&tId_); + } + void Run() override; private: -- Gitee