Files
zoneminder/src/zm_poll_thread.h
T
Nic BoetandClaude Opus 5.5 dcca007124 fix: let PollThread::Stop end the wait between polls
Monitor::Poll() ended by sleeping until 10 s after it started, and
PollThread::Stop() joins the thread, so Monitor::Close() waited for the
rest of that sleep: up to 10 s on every stop, reconnect and reload of a
zmc whose monitor has an ONVIF event listener, Janus, RTSP2Web, Go2RTC
or the Amcrest API enabled.

Wait for the next poll in PollThread::Run() on a condition variable
that Stop() notifies. Polls still start every 10 s.

fixes #5269

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 15:53:51 -05:00

34 lines
579 B
C++

#ifndef ZM_POLL_THREAD_H
#define ZM_POLL_THREAD_H
#include <atomic>
#include <condition_variable>
#include <memory>
#include <mutex>
#include <thread>
class Monitor;
class PollThread {
public:
explicit PollThread(Monitor *monitor);
~PollThread();
PollThread(PollThread &rhs) = delete;
PollThread(PollThread &&rhs) = delete;
void Start();
void Stop();
bool Stopped() const { return terminate_; }
private:
void Run();
Monitor *monitor_;
std::atomic<bool> terminate_;
std::mutex mutex_;
std::condition_variable cv_;
std::thread thread_;
};
#endif