15 #ifndef PSEN_SCAN_V2_STANDALONE_WATCHDOG_H 16 #define PSEN_SCAN_V2_STANDALONE_WATCHDOG_H 22 #include <condition_variable> 42 using Timeout =
const std::chrono::high_resolution_clock::duration;
45 Watchdog(
const Timeout& timeout,
const std::function<
void()>& timeout_callback);
66 std::condition_variable
cv_;
90 throw std::runtime_error(
"Timeout while waiting for timer thread to start");
97 std::unique_lock<std::mutex> lk(
cv_m_);
98 return cv_.wait_for(lk, timeout);
120 #endif // PSEN_SCAN_V2_STANDALONE_WATCHDOG_H Helper class to simplify the synchronization between different threads.
void reset()
Restarts the watchdog timer.
std::condition_variable cv_
const std::chrono::high_resolution_clock::duration Timeout
bool waitTillRelease(const std::chrono::duration< Rep, Period > &timeout) const
std::cv_status waitFor(const Timeout &timeout)
std::atomic_bool terminated_
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
Watchdog(const Timeout &timeout, const std::function< void()> &timeout_callback)
util::Barrier thread_startetd_barrier_
std::thread timer_thread_
Watchdog which continuously calls the specified timeout callback.