35 lines
662 B
C++
35 lines
662 B
C++
#ifndef COMPLIB_SERVER_HEALTHCHECKER_HPP
|
|
#define COMPLIB_SERVER_HEALTHCHECKER_HPP
|
|
|
|
#include <thread>
|
|
#include <chrono>
|
|
|
|
#define HEALTH_CHECK_TIMEOUT_MS 500
|
|
|
|
class HealthChecker {
|
|
public:
|
|
static HealthChecker &getInstance() {
|
|
static HealthChecker instance;
|
|
return instance;
|
|
}
|
|
|
|
HealthChecker(HealthChecker const &) = delete;
|
|
|
|
void operator=(HealthChecker const &) = delete;
|
|
|
|
void update();
|
|
|
|
private:
|
|
HealthChecker();
|
|
|
|
[[noreturn]] void check_loop();
|
|
|
|
typedef std::chrono::steady_clock clock;
|
|
|
|
std::thread check_thread;
|
|
std::chrono::time_point<clock> last_update;
|
|
bool stop_sent = false;
|
|
};
|
|
|
|
|
|
#endif //COMPLIB_SERVER_HEALTHCHECKER_HPP
|