:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/3.5/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/3.5/doc/classes/Semaphore.xml. .. _class_Semaphore: Semaphore ========= **Inherits:** :ref:`Reference` **<** :ref:`Object` A synchronization semaphore. Description ----------- A synchronization semaphore which can be used to synchronize multiple :ref:`Thread`\ s. Initialized to zero on creation. Be careful to avoid deadlocks. For a binary version, see :ref:`Mutex`. Tutorials --------- - :doc:`../tutorials/performance/threads/using_multiple_threads` Methods ------- +---------------------------------------+--------------------------------------------------------------+ | :ref:`Error` | :ref:`post` **(** **)** | +---------------------------------------+--------------------------------------------------------------+ | :ref:`Error` | :ref:`try_wait` **(** **)** | +---------------------------------------+--------------------------------------------------------------+ | :ref:`Error` | :ref:`wait` **(** **)** | +---------------------------------------+--------------------------------------------------------------+ Method Descriptions ------------------- .. _class_Semaphore_method_post: - :ref:`Error` **post** **(** **)** Lowers the ``Semaphore``, allowing one more thread in. \ **Note:** This method internals' can't possibly fail, but an error code is returned for backwards compatibility, which will always be :ref:`@GlobalScope.OK`. ---- .. _class_Semaphore_method_try_wait: - :ref:`Error` **try_wait** **(** **)** Like :ref:`wait`, but won't block, so if the value is zero, fails immediately and returns :ref:`@GlobalScope.ERR_BUSY`. If non-zero, it returns :ref:`@GlobalScope.OK` to report success. ---- .. _class_Semaphore_method_wait: - :ref:`Error` **wait** **(** **)** Waits for the ``Semaphore``, if its value is zero, blocks until non-zero. \ **Note:** This method internals' can't possibly fail, but an error code is returned for backwards compatibility, which will always be :ref:`@GlobalScope.OK`. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`