From 40f0b23482d37fd2b36b75f7cc6f74bfe0d7b0c2 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Tue, 26 Apr 2022 15:00:00 +0300 Subject: [PATCH] Create NavMap thread pool only when it's used, to prevent creating excessive amount of running threads. --- modules/navigation/nav_map.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp index 182de45e7c7e..cbc0adc57482 100644 --- a/modules/navigation/nav_map.cpp +++ b/modules/navigation/nav_map.cpp @@ -673,6 +673,9 @@ void NavMap::compute_single_step(uint32_t index, RvoAgent **agent) { void NavMap::step(real_t p_deltatime) { deltatime = p_deltatime; if (controlled_agents.size() > 0) { + if (step_work_pool.get_thread_count() == 0) { + step_work_pool.init(); + } step_work_pool.do_work( controlled_agents.size(), this, @@ -720,7 +723,6 @@ void NavMap::clip_path(const std::vector &p_navigation_polys } NavMap::NavMap() { - step_work_pool.init(); } NavMap::~NavMap() {