Must join the previous thread before starting a new one or we crash

This commit is contained in:
Isaac Connor 2021-04-17 11:31:36 -04:00
parent c479c6d68f
commit 1d034b16dd
2 changed files with 5 additions and 6 deletions

View File

@ -11,18 +11,17 @@ AnalysisThread::AnalysisThread(Monitor *monitor) :
AnalysisThread::~AnalysisThread() {
Stop();
if (thread_.joinable())
thread_.join();
if (thread_.joinable()) thread_.join();
}
void AnalysisThread::Start() {
if (thread_.joinable()) thread_.join();
terminate_ = false;
Debug(3, "Starting analysis thread");
thread_ = std::thread(&AnalysisThread::Run, this);
}
void AnalysisThread::Run() {
Debug(2, "AnalysisThread::Run() for %d", monitor_->Id());
Microseconds analysis_rate = Microseconds(monitor_->GetAnalysisRate());
Seconds analysis_update_delay = Seconds(monitor_->GetAnalysisUpdateDelay());
Debug(2, "AnalysisThread::Run() have update delay %d", analysis_update_delay);

View File

@ -10,11 +10,11 @@ DecoderThread::DecoderThread(Monitor *monitor) :
DecoderThread::~DecoderThread() {
Stop();
if (thread_.joinable())
thread_.join();
if (thread_.joinable()) thread_.join();
}
void DecoderThread::Start() {
if (thread_.joinable()) thread_.join();
terminate_ = false;
thread_ = std::thread(&DecoderThread::Run, this);
}