From 2245d597dee6109c5d37504e320bf4c99a126832 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 8 Jul 2025 11:02:58 -0400 Subject: [PATCH] MT#63171 AmThreadWatcher: stop thread When the thread watcher itself is in stopping state, request all watched threads to also stop. Change-Id: I964ba89519c1d8150756ef2688bb4b7c20be45c6 --- core/AmThread.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/AmThread.cpp b/core/AmThread.cpp index 67b1f1d9..1d6fbf77 100644 --- a/core/AmThread.cpp +++ b/core/AmThread.cpp @@ -169,7 +169,7 @@ void AmThreadWatcher::run() while (!stop_requested_unlocked() || !thread_list.empty()) { - run_cond.wait_for(_l, std::chrono::seconds(10)); + run_cond.wait_for(_l, std::chrono::seconds(1)); DBG("Thread watcher starting its work\n"); @@ -180,7 +180,14 @@ void AmThreadWatcher::run() AmThread* cur_thread = *it; _l.unlock(); + DBG("thread %lu is to be processed in thread watcher.\n", cur_thread->_pid); + + if (stop_requested()) { + DBG("thread watcher requesting thread %lu to stop.\n", cur_thread->_pid); + cur_thread->stop(); + } + if(cur_thread->is_stopped()){ DBG("thread %lu has been destroyed.\n", cur_thread->_pid); cur_thread->join();