From f131f78d3440c0896f901f3ca159a44c3f58c5df Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 26 Oct 2024 14:29:40 -0400 Subject: [PATCH] Add Join() function --- src/zm_analysis_thread.cpp | 3 +++ src/zm_analysis_thread.h | 1 + src/zm_decoder_thread.cpp | 4 ++++ src/zm_decoder_thread.h | 1 + 4 files changed, 9 insertions(+) diff --git a/src/zm_analysis_thread.cpp b/src/zm_analysis_thread.cpp index 517fb02a87..a646f4952f 100644 --- a/src/zm_analysis_thread.cpp +++ b/src/zm_analysis_thread.cpp @@ -24,6 +24,9 @@ void AnalysisThread::Start() { void AnalysisThread::Stop() { terminate_ = true; } +void AnalysisThread::Join() { + if (thread_.joinable()) thread_.join(); +} void AnalysisThread::Run() { while (!(terminate_ or zm_terminate)) { diff --git a/src/zm_analysis_thread.h b/src/zm_analysis_thread.h index c90bb2acb2..64ddf895cd 100644 --- a/src/zm_analysis_thread.h +++ b/src/zm_analysis_thread.h @@ -16,6 +16,7 @@ class AnalysisThread { void Start(); void Stop(); + void Join(); bool Stopped() const { return terminate_; } private: diff --git a/src/zm_decoder_thread.cpp b/src/zm_decoder_thread.cpp index 1f7946f955..fa36f06b97 100644 --- a/src/zm_decoder_thread.cpp +++ b/src/zm_decoder_thread.cpp @@ -23,6 +23,10 @@ void DecoderThread::Stop() { terminate_ = true; } +void DecoderThread::Join() { + if (thread_.joinable()) thread_.join(); +} + void DecoderThread::Run() { Debug(2, "DecoderThread::Run() for %d", monitor_->Id()); diff --git a/src/zm_decoder_thread.h b/src/zm_decoder_thread.h index 4fb8ea453d..e40b0e7ce2 100644 --- a/src/zm_decoder_thread.h +++ b/src/zm_decoder_thread.h @@ -16,6 +16,7 @@ class DecoderThread { void Start(); void Stop(); + void Join(); private: void Run();