fix event loop timing issue

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.
This commit is contained in:
Lion Kortlepel
2022-07-20 14:31:32 +02:00
parent 6a94060970
commit fd7b11f436
14 changed files with 71 additions and 51 deletions

View File

@@ -12,6 +12,7 @@ extern TSentry Sentry;
#include <functional>
#include <memory>
#include <mutex>
#include <shared_mutex>
#include <sstream>
#include <zlib.h>
@@ -96,6 +97,8 @@ public:
static void CheckForUpdates();
static std::array<uint8_t, 3> VersionStrToInts(const std::string& str);
static bool IsOutdated(const Version& Current, const Version& Newest);
static bool IsShuttingDown();
static void SleepSafeSeconds(size_t Seconds);
static void InitializeConsole() {
if (!mConsole) {
@@ -121,10 +124,14 @@ public:
static void SetSubsystemStatus(const std::string& Subsystem, Status status);
private:
static void SetShutdown(bool Val);
static inline SystemStatusMap mSystemStatusMap {};
static inline std::mutex mSystemStatusMapMutex {};
static inline std::string mPPS;
static inline std::unique_ptr<TConsole> mConsole;
static inline std::shared_mutex mShutdownMtx {};
static inline bool mShutdown { false };
static inline std::mutex mShutdownHandlersMutex {};
static inline std::deque<TShutdownHandler> mShutdownHandlers {};