CernVM-FS
2.12.0
|
#include <supervisor.h>
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_ |
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.
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.cc.
|
virtual |
Definition at line 13 of file supervisor.cc.
bool Supervisor::Run | ( | ) |
Definition at line 15 of file supervisor.cc.
Referenced by notify::DoSubscribe(), and NotificationClient::Run().
|
pure virtual |
Implemented in notify::SubscriberSupervisor.
Referenced by Run().
|
private |
Definition at line 40 of file supervisor.h.
Referenced by Run().
|
private |
Definition at line 39 of file supervisor.h.
Referenced by Run().