Update
This commit is contained in:
parent
d1e385a2a1
commit
1d91792c56
35 changed files with 2275 additions and 237 deletions
35
server_v2/include/HealthChecker.hpp
Normal file
35
server_v2/include/HealthChecker.hpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
#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
|
Reference in a new issue