mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-03 06:16:04 +00:00
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:
@@ -17,7 +17,6 @@ TPluginMonitor::TPluginMonitor(const fs::path& Path, std::shared_ptr<TLuaEngine>
|
||||
}
|
||||
|
||||
Application::RegisterShutdownHandler([this] {
|
||||
mShutdown = true;
|
||||
if (mThread.joinable()) {
|
||||
mThread.join();
|
||||
}
|
||||
@@ -30,7 +29,7 @@ void TPluginMonitor::operator()() {
|
||||
RegisterThread("PluginMonitor");
|
||||
beammp_info("PluginMonitor started");
|
||||
Application::SetSubsystemStatus("PluginMonitor", Application::Status::Good);
|
||||
while (!mShutdown) {
|
||||
while (!Application::IsShuttingDown()) {
|
||||
std::vector<std::string> ToRemove;
|
||||
for (const auto& Pair : mFileTimes) {
|
||||
try {
|
||||
@@ -61,7 +60,7 @@ void TPluginMonitor::operator()() {
|
||||
} catch (const std::exception& e) {
|
||||
ToRemove.push_back(Pair.first);
|
||||
}
|
||||
for (size_t i = 0; i < 3 && !mShutdown; ++i) {
|
||||
for (size_t i = 0; i < 3 && !Application::IsShuttingDown(); ++i) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user