diff --git a/Lts/DDS/DdsUnitTestsPlaceholder/mocks/MockDDS.cpp b/Lts/DDS/DdsUnitTestsPlaceholder/mocks/MockDDS.cpp index 2a0c6d626..ceb5b83d9 100644 --- a/Lts/DDS/DdsUnitTestsPlaceholder/mocks/MockDDS.cpp +++ b/Lts/DDS/DdsUnitTestsPlaceholder/mocks/MockDDS.cpp @@ -58,6 +58,8 @@ static void ensure_async_thread() { if (!g_async_running) { g_async_running = true; g_async_thread = std::thread(async_worker); + // detach worker so test binary exit doesn't require join; worker will exit when g_async_running is false + g_async_thread.detach(); } } @@ -118,17 +120,12 @@ void clear_all() { std::lock_guard lk(g_mtx); g_topics.clear(); } - // shutdown async worker gracefully - { - std::lock_guard lk(g_async_mtx); - g_async_running = false; - } - g_async_cv.notify_all(); - if (g_async_thread.joinable()) g_async_thread.join(); + // clear pending async queue; do not join detached worker { std::lock_guard lk(g_async_mtx); g_async_queue.clear(); } + g_async_cv.notify_all(); } } // namespace MockDDS