CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Supervisor Class Referenceabstract

#include <supervisor.h>

Inheritance diagram for Supervisor:

Public Member Functions

 Supervisor (uint64_t max_retries, uint64_t interval_sec)
virtual ~Supervisor ()
virtual bool Task ()=0
bool Run ()

Private Attributes

uint64_t max_retries_
uint64_t interval_

Detailed Description

This file is part of the CernVM File System. Run a task and retry in case of failure

This helper class is used to run a task and retry it in case of failure. Examples of use cases: long-running tasks, such a function with connects to a server and runs an event loop. If the connection fails, we want to reestablish it. If failures accumulate in the cooldown interval, we finally give up and exit.

The class is supposed to be derived: the task to be run is defined as the Task() virtual method. This method returns true in case of a normal termination and false, in case of failure.

The construction parameter of the class are the number of retries (max_retries) and the cooldown interval (interval_sec), given in seconds. The retry loop works as follows: in case of failure, the task will be re-run if number of failures in the last interval_sec is at most max_retries.

Definition at line 29 of file supervisor.h.

Constructor & Destructor Documentation

Supervisor::Supervisor ( uint64_t  max_retries,
uint64_t  interval_sec 

This file is part of the CernVM File System.

Definition at line 10 of file

Supervisor::~Supervisor ( )

Definition at line 13 of file

Member Function Documentation

bool Supervisor::Run ( )

Definition at line 15 of file

Referenced by notify::DoSubscribe(), and NotificationClient::Run().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool Supervisor::Task ( )
pure virtual

Implemented in notify::SubscriberSupervisor.

Referenced by Run().

Here is the caller graph for this function:

Member Data Documentation

uint64_t Supervisor::interval_

Definition at line 40 of file supervisor.h.

Referenced by Run().

uint64_t Supervisor::max_retries_

Definition at line 39 of file supervisor.h.

Referenced by Run().

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