Skip to content

Commit

Permalink
Merge pull request #60528 from bruvzg/thread_pool_delay
Browse files Browse the repository at this point in the history
Create NavMap thread pool only when it's used, to prevent creating excessive amount of running threads.
  • Loading branch information
akien-mga authored Apr 26, 2022
2 parents a8abdc9 + 40f0b23 commit 5c54770
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/navigation/nav_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -720,7 +723,6 @@ void NavMap::clip_path(const std::vector<gd::NavigationPoly> &p_navigation_polys
}

NavMap::NavMap() {
step_work_pool.init();
}

NavMap::~NavMap() {
Expand Down

0 comments on commit 5c54770

Please sign in to comment.