TSDuck v3.38-3738
MPEG Transport Stream Toolkit
No Matches
ts::WatchDog Class Reference

General-purpose timeout watchdog. More...

#include <tsWatchDog.h>

Inheritance diagram for ts::WatchDog:
Collaboration diagram for ts::WatchDog:

Public Member Functions

 WatchDog (WatchDogHandlerInterface *handler=nullptr, cn::milliseconds timeout=cn::milliseconds::zero(), int id=0, Report &log=(ts::NullReport::Instance()))
virtual ~WatchDog () override
void restart ()
 Restart the watchdog, the previous timeout is canceled.
void setTimeout (cn::milliseconds timeout, bool autoStart=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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ WatchDog()

ts::WatchDog::WatchDog ( WatchDogHandlerInterface handler = nullptr,
cn::milliseconds  timeout = cn::milliseconds::zero(),
int  id = 0,
Report log = (ts::NullReport::Instance()) 


[in]handlerInitial handler to call at expiration of the watchdog timeout.
[in]timeoutInitial watchdog timeout in milliseconds. Zero means no timeout.
[in]idApplication-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]logLog report.

Member Function Documentation

◆ setTimeout()

void ts::WatchDog::setTimeout ( cn::milliseconds  timeout,
bool  autoStart = false 

Set a new timeout value.

[in]timeoutNew watchdog timeout in milliseconds. Zero means no timeout.
[in]autoStartIf true and timeout is non zero, the timeout is automatically started. Otherwise, it is suspended. The previous timeout, if active, is automatically canceled.

◆ setWatchDogHandler()

void ts::WatchDog::setWatchDogHandler ( WatchDogHandlerInterface h)

Replace the watchdog handler.

[in]hThe new handler. Can be zero.

◆ setWatchDogId()

void ts::WatchDog::setWatchDogId ( int  id)

Set some arbitrary "watchdog id" value.

[in]idApplication-defined watchdog id to assign.

◆ watchDogId()

int ts::WatchDog::watchDogId ( ) const

Get the "watchdog id" value, as previously stored by the application.

The application-defined watchdog id.

The documentation for this class was generated from the following file: