Make AnalysisThread::Stop wait for the thread to stop
parent
bd711c5230
commit
ed66f1b1a8
|
@ -11,7 +11,6 @@ AnalysisThread::AnalysisThread(Monitor *monitor) :
|
||||||
|
|
||||||
AnalysisThread::~AnalysisThread() {
|
AnalysisThread::~AnalysisThread() {
|
||||||
Stop();
|
Stop();
|
||||||
if (thread_.joinable()) thread_.join();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnalysisThread::Start() {
|
void AnalysisThread::Start() {
|
||||||
|
@ -21,6 +20,11 @@ void AnalysisThread::Start() {
|
||||||
thread_ = std::thread(&AnalysisThread::Run, this);
|
thread_ = std::thread(&AnalysisThread::Run, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AnalysisThread::Stop() {
|
||||||
|
terminate_ = true;
|
||||||
|
if (thread_.joinable()) thread_.join();
|
||||||
|
}
|
||||||
|
|
||||||
void AnalysisThread::Run() {
|
void AnalysisThread::Run() {
|
||||||
while (!(terminate_ or zm_terminate)) {
|
while (!(terminate_ or zm_terminate)) {
|
||||||
// Some periodic updates are required for variable capturing framerate
|
// Some periodic updates are required for variable capturing framerate
|
||||||
|
|
|
@ -15,7 +15,7 @@ class AnalysisThread {
|
||||||
AnalysisThread(AnalysisThread &&rhs) = delete;
|
AnalysisThread(AnalysisThread &&rhs) = delete;
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
void Stop() { terminate_ = true; }
|
void Stop();
|
||||||
bool Stopped() const { return terminate_; }
|
bool Stopped() const { return terminate_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue