Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/prodeveloper0/watchdogtimer

The WatchDogTimer Library written to be fully compatible with C++11 and as header-only to use easily.
https://github.com/prodeveloper0/watchdogtimer

cpp-library cpp11 header-only watchdogtimer wdt

Last synced: about 2 months ago
JSON representation

The WatchDogTimer Library written to be fully compatible with C++11 and as header-only to use easily.

Awesome Lists containing this project

README

        

# WatchDogTimer
The WatchDogTimer Library written to be fully compatible with C++11 and as header-only to use easily.

## How to use
### 0. Including `wdt.hpp` header file on top of your cpp file.
```C++
#include
// Or
#include "wdt.hpp"
```

### 1. Subtyping your dog with `WatchdogTimer` class and implementing `on_timeout()` to bark to you.
```C++
class MyWatchdogTimer : public WatchdogTimer
{
public:
virtual void on_timeout()
{
// To do when your dog is bark.
...
}
};
```

### 2. Creating your dog with subtyped `WatchdogTimer` class.
```C++
MyWatchdogTimer wdt;
```

### 3. Kicking your dog by calling `kick()`.
```C++
// wdt is scheduled to call on_timeout() after 100ms once.
wdt.kick(100);
```
As well as, you can also kick your dog to watch forever by calling `kick()` with `loop` flag `true`.
```C++
// wdt is scheduled to call on_timeout() after 100ms forever.
wdt.kick(100, true);
```

### 4. Feeding your dog repeatedly to be silence by calling `clear()` repeatedly.
```C++
while (true)
{
// To do somethings
...

if (there_is_no_problem)
wdt.clear();
}
```

### 5. Finally, Stopping your dog to watch by calling `stop()`.
```C++
wdt.stop();
```