April 2020
Intermediate to advanced
412 pages
9h 58m
English
We will create an application that will define the Watchdog class and provide an example of its usage. Follow these steps:
#include <chrono>#include <iostream>#include <thread>#include <unistd.h>using namespace std::chrono_literals;
class Watchdog { std::chrono::seconds seconds; public: Watchdog(std::chrono::seconds seconds): seconds(seconds) { feed(); } ~Watchdog() { alarm(0); } void feed() { alarm(seconds.count()); }};