// // Created by mwo on 12/07/18. // #ifndef OPENMONERO_MYSQLPING_H #define OPENMONERO_MYSQLPING_H #include "MySqlConnector.h" #include #include #include namespace xmreg { class MysqlPing { public: enum class StopReason {NotYetStopped, PingFailed, PointerExpired}; MysqlPing(std::shared_ptr _conn, uint64_t _ping_time = 300); void operator()(); void stop() {keep_looping = false;} uint64_t get_counter() const {return counter;} StopReason get_stop_reason() const {return why_stoped;}; MysqlPing(MysqlPing&&) = default; MysqlPing& operator=(MysqlPing&&) = default; private: std::weak_ptr conn; uint64_t ping_time; // in seconds atomic keep_looping {true}; atomic counter {0}; atomic why_stoped {StopReason::NotYetStopped}; }; } #endif //OPENMONERO_MYSQLPING_H