mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-01 15:26:59 +00:00
The event loop tries to run no faster than every 10ms. If it detects that it goes faster, it would incorrectly calculate the difference, and then wait (what I assume was) way too long or too short. Either way, now it's fixed and it correctly works, even when introducing new lua states.
27 lines
665 B
C++
27 lines
665 B
C++
#pragma once
|
|
|
|
#include "Common.h"
|
|
#include "TServer.h"
|
|
#include <optional>
|
|
|
|
class TNetwork;
|
|
|
|
class TPPSMonitor : public IThreaded {
|
|
public:
|
|
explicit TPPSMonitor(TServer& Server);
|
|
|
|
void operator()() override;
|
|
|
|
void SetInternalPPS(int NewPPS) { mInternalPPS = NewPPS; }
|
|
void IncrementInternalPPS() { ++mInternalPPS; }
|
|
[[nodiscard]] int InternalPPS() const { return mInternalPPS; }
|
|
void SetNetwork(TNetwork& Server) { mNetwork = std::ref(Server); }
|
|
|
|
private:
|
|
TNetwork& Network() { return mNetwork->get(); }
|
|
|
|
TServer& mServer;
|
|
std::optional<std::reference_wrapper<TNetwork>> mNetwork { std::nullopt };
|
|
int mInternalPPS { 0 };
|
|
};
|