This repository has been archived on 2025-06-01. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
compLIB/server_v2/include/HealthChecker.hpp
Konstantin Lampalzer 1d91792c56 Update
2022-10-05 23:13:40 +02:00

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