mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-30 12:14:36 -05:00
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>
34 lines
579 B
C++
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
|