TSDuck v3.46-4964
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches

#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 ()
void setTimeout (cn::milliseconds timeout, bool auto_start=false)
void setWatchDogHandler (WatchDogHandlerInterface *h)
void setWatchDogId (int id)
void suspend ()
int watchDogId () const

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()) )

Constructor.

Parameters
[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.

◆ ~WatchDog()

virtual ts::WatchDog::~WatchDog ( )
overridevirtual

Destructor.

Member Function Documentation

◆ setTimeout()

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

Set a new timeout value.

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

◆ restart()

void ts::WatchDog::restart ( )

Restart the watchdog, the previous timeout is canceled.

◆ suspend()

void ts::WatchDog::suspend ( )

Suspend the watchdog, the previous timeout is canceled.

◆ setWatchDogHandler()

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

Replace the watchdog handler.

Parameters
[in]hThe new handler. Can be zero.

◆ setWatchDogId()

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

Set some arbitrary "watchdog id" value.

Parameters
[in]idApplication-defined watchdog id to assign.

◆ watchDogId()

int ts::WatchDog::watchDogId ( ) const
inline

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

Returns
The application-defined watchdog id.

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