Monitor: Make analysis_thread a unique_ptr

The AnalysisThread object is owned by the Monitor. Signal this by using unique_ptr.
This commit is contained in:
Peter Keresztes Schmidt
2021-03-21 23:07:19 +01:00
parent 4c988860d5
commit fee5ecd72f
4 changed files with 15 additions and 17 deletions

View File

@@ -4,10 +4,8 @@
#include "zm_signal.h"
#include "zm_utils.h"
//AnalysisThread::AnalysisThread(std::shared_ptr<Monitor> monitor) :
AnalysisThread::AnalysisThread(Monitor* monitor) :
AnalysisThread::AnalysisThread(Monitor *monitor) :
monitor_(monitor), terminate_(false) {
//monitor_(std::move(monitor)), terminate_(false) {
thread_ = std::thread(&AnalysisThread::Run, this);
}
@@ -43,7 +41,7 @@ void AnalysisThread::Run() {
Debug(2, "Analyzing");
if (!monitor_->Analyse()) {
if ( !(terminate_ or zm_terminate) ) {
if (!(terminate_ or zm_terminate)) {
Microseconds sleep_for = monitor_->Active() ? Microseconds(ZM_SAMPLE_RATE) : Microseconds(ZM_SUSPENDED_RATE);
Debug(2, "Sleeping for %" PRId64 "us", int64(sleep_for.count()));
std::this_thread::sleep_for(sleep_for);