Go to the documentation of this file.
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_;
72 : timer_thread_([this, timeout, timeout_callback]() {
86 if (!thread_startetd_barrier_.waitTillRelease(timeout))
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
void reset()
Restarts the watchdog timer.
const std::chrono::high_resolution_clock::duration Timeout
Helper class to simplify the synchronization between different threads.
std::atomic_bool terminated_
Watchdog(const Timeout &timeout, const std::function< void()> &timeout_callback)
std::condition_variable cv_
std::cv_status waitFor(const Timeout &timeout)
util::Barrier thread_startetd_barrier_
std::thread timer_thread_
Watchdog which continuously calls the specified timeout callback.
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
psen_scan_v2
Author(s): Pilz GmbH + Co. KG
autogenerated on Sat Jun 22 2024 02:46:12