From cbbd586347915dff797958b4c850776c9edc8a49 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Wed, 22 Jan 2025 13:01:36 -0600 Subject: [PATCH] refactor --- repertory/librepertory/include/events/t_event_system.hpp | 7 +++++-- .../librepertory/src/utils/single_thread_service_base.cpp | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/repertory/librepertory/include/events/t_event_system.hpp b/repertory/librepertory/include/events/t_event_system.hpp index e3090714..585df825 100644 --- a/repertory/librepertory/include/events/t_event_system.hpp +++ b/repertory/librepertory/include/events/t_event_system.hpp @@ -232,11 +232,14 @@ public: stop_requested_ = true; + std::unique_ptr thread{nullptr}; + std::swap(thread, event_thread_); + event_notify_.notify_all(); lock.unlock(); - event_thread_->join(); - event_thread_.reset(); + thread->join(); + thread.reset(); process_events(); } diff --git a/repertory/librepertory/src/utils/single_thread_service_base.cpp b/repertory/librepertory/src/utils/single_thread_service_base.cpp index 6e31a98e..1d7fdb01 100644 --- a/repertory/librepertory/src/utils/single_thread_service_base.cpp +++ b/repertory/librepertory/src/utils/single_thread_service_base.cpp @@ -60,10 +60,11 @@ void single_thread_service_base::stop() { event_system::instance().raise(service_name_); + stop_requested_ = true; + std::unique_ptr thread{nullptr}; std::swap(thread, thread_); - stop_requested_ = true; notify_.notify_all(); lock.unlock();