Skip to content

Commit bc59e55

Browse files
authored
Merge pull request #11726 from smix8/thread_safe_api
Add Navigation entry to thread-safe apis doc
2 parents 1c38c10 + dca0a41 commit bc59e55

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tutorials/performance/thread_safe_apis.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,26 @@ on separate threads (making them thread-safe), enable the following project sett
109109
- **PhysicsServer2D:** :ref:`Physics > 2D > Run on Separate Thread <class_ProjectSettings_property_physics/2d/run_on_separate_thread>`.
110110
- **PhysicsServer3D:** :ref:`Physics > 3D > Run on Separate Thread <class_ProjectSettings_property_physics/3d/run_on_separate_thread>`.
111111

112+
Navigation
113+
----------
114+
115+
:ref:`NavigationServer2D<class_NavigationServer2D>` and :ref:`NavigationServer3D<class_NavigationServer3D>` are both thread-safe and thread-friendly.
116+
117+
The navigation-related query functions can be called by threads and run in true parallel.
118+
119+
By default, a conservative number of threads is supported running in true parallel on navigation maps before
120+
additional threads have to wait for map data access at a semaphore.
121+
To increase the number of threads that can run simultaneously on map data,
122+
set :ref:`Navigation > Pathfinding > Max Threads <class_ProjectSettings_property_navigation/pathfinding/max_threads>`.
123+
124+
The navigation server-related resources like NavigationSourceGeometryData, NavigationMesh, and NavigationPolygon are all thread-safe but not necessarily thread-friendly.
125+
They use internal read-write locks for thread-safety so editing the same resource (e.g. a single big navmesh) on multiple threads at the same time can cause thread congestion.
126+
127+
The navigation-related helper classes like :ref:`AStar2D<class_AStar2D>`, :ref:`AStar3D<class_AStar3D>`, and :ref:`AStarGrid2D<class_AStarGrid2D>` are **not** thread-safe.
128+
They can be used with threads to some limited capacity, but using two or more threads on the same AStar object causes corruption.
129+
For example, using a dedicated background thread per AStar object to populate points or do queries works,
130+
but two threads using the same AStar object would corrupt each other's data.
131+
112132
GDScript arrays and dictionaries
113133
--------------------------------
114134

0 commit comments

Comments
 (0)