From 3c8b590925f51bc1fef912e668287bacf0fdb73e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 17 Jun 2022 17:23:33 -0400 Subject: [PATCH] Make DecoderThread::Stop wait for the thread to stop --- src/zm_decoder_thread.cpp | 7 ++++++- src/zm_decoder_thread.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/zm_decoder_thread.cpp b/src/zm_decoder_thread.cpp index 0ffeadfc5..5c1033985 100644 --- a/src/zm_decoder_thread.cpp +++ b/src/zm_decoder_thread.cpp @@ -10,7 +10,6 @@ DecoderThread::DecoderThread(Monitor *monitor) : DecoderThread::~DecoderThread() { Stop(); - if (thread_.joinable()) thread_.join(); } void DecoderThread::Start() { @@ -18,6 +17,12 @@ void DecoderThread::Start() { terminate_ = false; thread_ = std::thread(&DecoderThread::Run, this); } + +void DecoderThread::Stop() { + terminate_ = true; + 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 62b2f0d23..4fb8ea453 100644 --- a/src/zm_decoder_thread.h +++ b/src/zm_decoder_thread.h @@ -15,7 +15,7 @@ class DecoderThread { DecoderThread(DecoderThread &&rhs) = delete; void Start(); - void Stop() { terminate_ = true; } + void Stop(); private: void Run();