AUI Framework  master
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
AWatchdog Class Reference

Watchdog helper class. More...

#include <AUI/Util/AWatchdog.h>

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.
 
bool isHang () const noexcept
 Checks for hang state.
 

Detailed Description#

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

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
nodiscardnoexcept
Returns
true, if runOperation exceeded mHangDuration.

◆ runOperation()#

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

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