fix(Core/Maps): prevet a crash occurring when shutting the server down. (#7387)

This commit is contained in:
lineagedr
2021-08-20 01:01:48 +03:00
committed by GitHub
parent 6693bf703c
commit ff7d6d2dae

View File

@@ -67,6 +67,7 @@ MapUpdater::~MapUpdater()
void MapUpdater::activate(size_t num_threads) void MapUpdater::activate(size_t num_threads)
{ {
_workerThreads.reserve(num_threads);
for (size_t i = 0; i < num_threads; ++i) for (size_t i = 0; i < num_threads; ++i)
{ {
_workerThreads.push_back(std::thread(&MapUpdater::WorkerThread, this)); _workerThreads.push_back(std::thread(&MapUpdater::WorkerThread, this));
@@ -82,10 +83,13 @@ void MapUpdater::deactivate()
_queue.Cancel(); _queue.Cancel();
for (auto& thread : _workerThreads) for (auto& thread : _workerThreads)
{
if (thread.joinable())
{ {
thread.join(); thread.join();
} }
} }
}
void MapUpdater::wait() void MapUpdater::wait()
{ {