Last change
on this file since 60 was 13, checked in by Bayard Gildas, 9 years ago |
formatting script + include reformatted
|
File size:
886 bytes
|
Rev | Line | |
---|
[2] | 1 | // %flair:license{
|
---|
[13] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[2] | 4 | // %flair:license}
|
---|
| 5 | /*!
|
---|
| 6 | * \file Watchdog.h
|
---|
| 7 | * \brief Watchdog Class
|
---|
| 8 | * \author Gildas Bayard, Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 9 | * \date 2016/02/25
|
---|
| 10 | * \version 1.0
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 | #ifndef WATCHDOG_H
|
---|
| 14 | #define WATCHDOG_H
|
---|
| 15 |
|
---|
| 16 | #include <Thread.h>
|
---|
| 17 | #include <functional>
|
---|
| 18 |
|
---|
| 19 | namespace flair {
|
---|
| 20 | namespace core {
|
---|
| 21 |
|
---|
[13] | 22 | /*! \class Watchdog
|
---|
| 23 | *
|
---|
| 24 | * \brief Watchdog class
|
---|
| 25 | *
|
---|
| 26 | * Calls a given function if not touched within a specified period of time
|
---|
| 27 | *
|
---|
| 28 | */
|
---|
| 29 | class Watchdog : public Thread {
|
---|
| 30 | public:
|
---|
| 31 | Watchdog(const Object *parent, std::function<void()> _expired, Time _timer);
|
---|
| 32 | ~Watchdog();
|
---|
[2] | 33 |
|
---|
[13] | 34 | // reset the timer
|
---|
| 35 | void Touch();
|
---|
| 36 | void SetTimer(Time _Timer);
|
---|
[2] | 37 |
|
---|
[13] | 38 | private:
|
---|
| 39 | void Run();
|
---|
| 40 | std::function<void()> expired;
|
---|
| 41 | Time timer;
|
---|
| 42 | };
|
---|
| 43 |
|
---|
[2] | 44 | } // end namespace core
|
---|
| 45 | } // end namespace flair
|
---|
| 46 |
|
---|
| 47 | #endif // WATCHDOG_H
|
---|
Note:
See
TracBrowser
for help on using the repository browser.