mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-03 14:26:09 +00:00
clear up heartbeat code, improve logs in debug builds
This commit is contained in:
committed by
Anonymous275
parent
ab44ac8c15
commit
8e4006fc38
@@ -18,11 +18,16 @@ void THeartbeatThread::operator()() {
|
||||
Body = GenerateCall();
|
||||
// a hot-change occurs when a setting has changed, to update the backend of that change.
|
||||
auto Now = std::chrono::high_resolution_clock::now();
|
||||
if (((Now - LastNormalUpdateTime) < std::chrono::seconds(5))
|
||||
|| (Last == Body && (Now - LastNormalUpdateTime) < std::chrono::seconds(30))) {
|
||||
bool Unchanged = Last == Body;
|
||||
auto TimePassed = (Now - LastNormalUpdateTime);
|
||||
auto Threshold = Unchanged ? 30 : 5;
|
||||
if (TimePassed < std::chrono::seconds(Threshold)) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
continue;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
debug("heartbeat @ " + std::to_string(std::chrono::duration_cast<std::chrono::seconds>(TimePassed).count()));
|
||||
#endif // DEBUG
|
||||
|
||||
Last = Body;
|
||||
LastNormalUpdateTime = Now;
|
||||
|
||||
Reference in New Issue
Block a user