Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
psen_scan_v2_standalone::util::Watchdog Class Reference

Watchdog which continuously calls the specified timeout callback. More...

#include <watchdog.h>

Public Types

using Timeout = const std::chrono::high_resolution_clock::duration
 

Public Member Functions

void reset ()
 Restarts the watchdog timer. More...
 
 Watchdog (const Timeout &timeout, const std::function< void()> &timeout_callback)
 
 ~Watchdog ()
 

Private Member Functions

std::cv_status waitFor (const Timeout &timeout)
 

Private Attributes

std::condition_variable cv_
 
std::mutex cv_m_
 
std::atomic_bool terminated_ { false }
 
util::Barrier thread_startetd_barrier_
 
std::thread timer_thread_
 

Detailed Description

Watchdog which continuously calls the specified timeout callback.

After the specified timeout time has passed the timeout_callback is called and the timer restarts. This continues as long as the watchdog exists.

Definition at line 39 of file watchdog.h.

Member Typedef Documentation

◆ Timeout

using psen_scan_v2_standalone::util::Watchdog::Timeout = const std::chrono::high_resolution_clock::duration

Definition at line 42 of file watchdog.h.

Constructor & Destructor Documentation

◆ Watchdog()

psen_scan_v2_standalone::util::Watchdog::Watchdog ( const Timeout timeout,
const std::function< void()> &  timeout_callback 
)
inline

Definition at line 71 of file watchdog.h.

◆ ~Watchdog()

psen_scan_v2_standalone::util::Watchdog::~Watchdog ( )
inline

Definition at line 106 of file watchdog.h.

Member Function Documentation

◆ reset()

void psen_scan_v2_standalone::util::Watchdog::reset ( )
inline

Restarts the watchdog timer.

Definition at line 101 of file watchdog.h.

◆ waitFor()

std::cv_status psen_scan_v2_standalone::util::Watchdog::waitFor ( const Timeout timeout)
inlineprivate
Returns
std::cv_status::timeout if the specified timeout has expired or std::cv_status::no_timeout if the condition variable was notified.
Note
The function may also return spuriously with std::cv_status::no_timeout even if the condition variable was not notified. For more info see: https://en.cppreference.com/w/cpp/thread/condition_variable/wait_for

Definition at line 95 of file watchdog.h.

Member Data Documentation

◆ cv_

std::condition_variable psen_scan_v2_standalone::util::Watchdog::cv_
private

Definition at line 66 of file watchdog.h.

◆ cv_m_

std::mutex psen_scan_v2_standalone::util::Watchdog::cv_m_
private

Definition at line 67 of file watchdog.h.

◆ terminated_

std::atomic_bool psen_scan_v2_standalone::util::Watchdog::terminated_ { false }
private

Definition at line 65 of file watchdog.h.

◆ thread_startetd_barrier_

util::Barrier psen_scan_v2_standalone::util::Watchdog::thread_startetd_barrier_
private

Definition at line 64 of file watchdog.h.

◆ timer_thread_

std::thread psen_scan_v2_standalone::util::Watchdog::timer_thread_
private

Definition at line 68 of file watchdog.h.


The documentation for this class was generated from the following file:


psen_scan_v2
Author(s): Pilz GmbH + Co. KG
autogenerated on Sat Jun 22 2024 02:46:12