AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
AWatchdog Class Reference

Watchdog helper class. More...

Detailed Description

Watchdog helper class.

Watchdog is either hardware or software (as in this case) module which detects hangs of subject (in this case, of a callback).

AWatchdog catches ANR (Application Not Responsive) errors in GUI AUI applications.

It's important to periodically call AWatchdog::isHang in order to check for hangs. It can be done via separate thread or AUI's timers (separate thread is more reliable).

See also
AWatchdog::run
AWatchdog::isHang

Public Member Functions

 AWatchdog (std::chrono::high_resolution_clock::duration hangDuration=std::chrono::seconds(10))
 
template<aui::invocable Operation>
auto runOperation (Operation &&operation) -> decltype(operation())
 Runs callback which is subject to check for hangs. More...
 
bool isHang () const noexcept
 Checks for hang state. More...
 

Constructor & Destructor Documentation

◆ AWatchdog()

AWatchdog::AWatchdog ( std::chrono::high_resolution_clock::duration  hangDuration = std::chrono::seconds(10))
inline
Parameters
hangDurationthe time frame exceeding which considered as hang.

Member Function Documentation

◆ isHang()

bool AWatchdog::isHang ( ) const
noexcept

Checks for hang state.

Returns
true, if runOperation exceeded mHangDuration.

◆ runOperation()

template<aui::invocable Operation>
auto AWatchdog::runOperation ( Operation &&  operation) -> decltype(operation())
inline

Runs callback which is subject to check for hangs.

If execution time of operation exceeds mHangDuration, the operation is considered hang and AWatchdog::isHang would report hang state when AWatchdog::isHang is called.

#include <AUI/Util/AWatchdog.h>


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