Files
zoneminder/src/zm_poll_thread.cpp
Aaron Kling c4683d90a9 Format code using astyle google format
Commands used:
astyle --style=google --indent=spaces=2 --keep-one-line-blocks src/*.cpp
astyle --style=google --indent=spaces=2 --keep-one-line-blocks src/*.h
2024-03-26 13:43:58 -05:00

33 lines
652 B
C++

#include "zm_poll_thread.h"
#include "zm_monitor.h"
#include "zm_signal.h"
#include "zm_time.h"
PollThread::PollThread(Monitor *monitor) :
monitor_(monitor), terminate_(false) {
thread_ = std::thread(&PollThread::Run, this);
}
PollThread::~PollThread() {
Stop();
}
void PollThread::Start() {
if (thread_.joinable()) thread_.join();
terminate_ = false;
Debug(3, "Starting polling thread");
thread_ = std::thread(&PollThread::Run, this);
}
void PollThread::Stop() {
terminate_ = true;
if (thread_.joinable()) {
thread_.join();
}
}
void PollThread::Run() {
while (!(terminate_ or zm_terminate)) {
monitor_->Poll();
}
}