@@ -150,11 +150,56 @@ scripting API.
150150.. |typed_dictionary | replace :: `TypedDictionary <https://github.com/godotengine/godot/blob/master/core/variant/typed_dictionary.h >`__
151151.. |pair | replace :: `Pair <https://github.com/godotengine/godot/blob/master/core/templates/pair.h >`__
152152
153- Thread safety
154- ~~~~~~~~~~~~~
153+ .. _doc_core_concurrency_types :
154+
155+ Multithreading / Concurrency
156+ ----------------------------
157+
158+ .. seealso ::
159+
160+ You can find more information on multithreading strategies at :ref: `doc_using_multiple_threads `.
155161
156162None of Godot's containers are thread-safe. When you expect multiple threads to access them, you must use multithread
157- protections, like ``Mutex `` or ``Semaphore ``.
163+ protections.
164+
165+ Note that some of the types listed here are also available through the bindings, but the binding types are wrapped with
166+ :ref: `class_RefCounted ` (found in the ``CoreBind:: `` namespace). Prefer the primitives listed here when possible, for
167+ efficiency reasons.
168+
169+ +-----------------------+------------------------------+---------------------------------------------------------------------------------------+
170+ | Godot datatype | Closest C++ STL datatype | Comment |
171+ +=======================+==============================+=======================================================================================+
172+ | |mutex | | ``std::recursive_mutex `` | Recursive mutex type. Use ``MutexLock lock(mutex) `` to lock it. |
173+ +-----------------------+------------------------------+---------------------------------------------------------------------------------------+
174+ | |binary_mutex | | ``std::mutex `` | Non-recursive mutex type. Use ``MutexLock lock(mutex) `` to lock it. |
175+ +-----------------------+------------------------------+---------------------------------------------------------------------------------------+
176+ | |rw_lock | | ``std::shared_timed_mutex `` | Read-write aware mutex type. Use ``RWLockRead lock(mutex) `` or |
177+ | | | ``RWLockWrite lock(mutex) `` to lock it. |
178+ +-----------------------+------------------------------+---------------------------------------------------------------------------------------+
179+ | |safe_binary_mutex | | | Recursive mutex type that can be used with ``ConditionVariable ``. |
180+ | | | Use ``MutexLock lock(mutex) `` to lock it. |
181+ +-----------------------+------------------------------+---------------------------------------------------------------------------------------+
182+ | |condition_variable | | ``std::condition_variable `` | Condition variable type, used with ``SafeBinaryMutex ``. |
183+ +-----------------------+------------------------------+---------------------------------------------------------------------------------------+
184+ | |semaphore | | ``std::counting_semaphore `` | Counting semaphore type. |
185+ +-----------------------+------------------------------+---------------------------------------------------------------------------------------+
186+ | |safe_numeric | | ``std::atomic `` | Templated atomic type, designed for numbers. |
187+ +-----------------------+------------------------------+---------------------------------------------------------------------------------------+
188+ | |safe_flag | | ``std::atomic_bool `` | Bool atomic type. |
189+ +-----------------------+------------------------------+---------------------------------------------------------------------------------------+
190+ | |safe_ref_count | | ``std::atomic `` | Atomic type designed for reference counting. Will refuse to increment the |
191+ | | | reference count if it is 0. |
192+ +-----------------------+------------------------------+---------------------------------------------------------------------------------------+
193+
194+ .. |mutex | replace :: `Mutex <https://github.com/godotengine/godot/blob/master/core/os/mutex.h >`__
195+ .. |binary_mutex | replace :: `BinaryMutex <https://github.com/godotengine/godot/blob/master/core/os/mutex.h >`__
196+ .. |rw_lock | replace :: `RWLock <https://github.com/godotengine/godot/blob/master/core/os/rw_lock.h >`__
197+ .. |safe_binary_mutex | replace :: `SafeBinaryMutex <https://github.com/godotengine/godot/blob/master/core/os/safe_binary_mutex.h >`__
198+ .. |condition_variable | replace :: `ConditionVariable <https://github.com/godotengine/godot/blob/master/core/os/condition_variable.h >`__
199+ .. |semaphore | replace :: `Semaphore <https://github.com/godotengine/godot/blob/master/core/os/semaphore.h >`__
200+ .. |safe_numeric | replace :: `SafeNumeric <https://github.com/godotengine/godot/blob/master/core/templates/safe_refcount.h >`__
201+ .. |safe_flag | replace :: `SafeFlag <https://github.com/godotengine/godot/blob/master/core/templates/safe_refcount.h >`__
202+ .. |safe_ref_count | replace :: `SafeRefCount <https://github.com/godotengine/godot/blob/master/core/templates/safe_refcount.h >`__
158203
159204Math types
160205----------
0 commit comments