CernVM-FS  2.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
supervisor.cc
Go to the documentation of this file.
1 
5 #include "supervisor.h"
6 
7 #include "logging.h"
8 #include "platform.h"
9 
10 Supervisor::Supervisor(uint64_t max_retries, uint64_t interval_sec)
11  : max_retries_(max_retries), interval_(interval_sec) {}
12 
14 
16  uint64_t retries = 0;
17  uint64_t t0 = platform_monotonic_time();
18  bool result = false;
19  do {
20  result = Task();
21  uint64_t t1 = platform_monotonic_time();
22  if (t1 - t0 < interval_) {
23  retries += 1;
24  } else {
25  t0 = t1;
26  retries = 0;
27  }
28  } while (!result && (retries <= max_retries_));
29 
30  return result;
31 }
uint64_t max_retries_
Definition: supervisor.h:39
virtual bool Task()=0
bool Run()
Definition: supervisor.cc:15
Supervisor(uint64_t max_retries, uint64_t interval_sec)
Definition: supervisor.cc:10
uint64_t platform_monotonic_time()
virtual ~Supervisor()
Definition: supervisor.cc:13
uint64_t interval_
Definition: supervisor.h:40