![]() |
TSDuck v3.43-4480
MPEG Transport Stream Toolkit
|
General-purpose timeout watchdog. More...
#include <tsWatchDog.h>


Public Member Functions | |
| WatchDog (WatchDogHandlerInterface *handler=nullptr, cn::milliseconds timeout=cn::milliseconds::zero(), int id=0, Report &log=(ts::NullReport::Instance())) | |
| Constructor. | |
| virtual | ~WatchDog () override |
| Destructor. | |
| void | restart () |
| Restart the watchdog, the previous timeout is canceled. | |
| void | setTimeout (cn::milliseconds timeout, bool auto_start=false) |
| Set a new timeout value. | |
| void | setWatchDogHandler (WatchDogHandlerInterface *h) |
| Replace the watchdog handler. | |
| void | setWatchDogId (int id) |
| Set some arbitrary "watchdog id" value. | |
| void | suspend () |
| Suspend the watchdog, the previous timeout is canceled. | |
| int | watchDogId () const |
| Get the "watchdog id" value, as previously stored by the application. | |
General-purpose timeout watchdog.
The watchdog is initially suspended. A call to restart() reinitializes the timer and starts the watchdog. After the timeout, the watchdog automatically triggers a "next input". To avoid this, restart() or suspend() must be called before the timeout expires.
A WatchDog instance contains an internal thread which is started in the constructor and terminated in the destructor.
| ts::WatchDog::WatchDog | ( | WatchDogHandlerInterface * | handler = nullptr, |
| cn::milliseconds | timeout = cn::milliseconds::zero(), |
||
| int | id = 0, |
||
| Report & | log = (ts::NullReport::Instance()) |
||
| ) |
Constructor.
| [in] | handler | Initial handler to call at expiration of the watchdog timeout. |
| [in] | timeout | Initial watchdog timeout in milliseconds. Zero means no timeout. |
| [in] | id | Application-defined watchdog id to assign. This value is chosen and set by the application. It can be retrieved later if a handler is used by several watchdogs. The id is not interpreted by the watchdog, it is only stored for the application. |
| [in,out] | log | Log report. |
| void ts::WatchDog::setTimeout | ( | cn::milliseconds | timeout, |
| bool | auto_start = false |
||
| ) |
Set a new timeout value.
| [in] | timeout | New watchdog timeout in milliseconds. Zero means no timeout. |
| [in] | auto_start | If true and timeout is non zero, the timeout is automatically started. Otherwise, it is suspended. The previous timeout, if active, is automatically canceled. |
| void ts::WatchDog::setWatchDogHandler | ( | WatchDogHandlerInterface * | h | ) |
Replace the watchdog handler.
| [in] | h | The new handler. Can be zero. |
|
inline |
Set some arbitrary "watchdog id" value.
| [in] | id | Application-defined watchdog id to assign. |
|
inline |
Get the "watchdog id" value, as previously stored by the application.