class_semaphore.rst 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Semaphore.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Semaphore:
  5. Semaphore
  6. =========
  7. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. A synchronization Semaphore.
  12. Methods
  13. -------
  14. +---------------------------------------+------------------------------------------------------+
  15. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`post<class_Semaphore_method_post>` **(** **)** |
  16. +---------------------------------------+------------------------------------------------------+
  17. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`wait<class_Semaphore_method_wait>` **(** **)** |
  18. +---------------------------------------+------------------------------------------------------+
  19. Description
  20. -----------
  21. A synchronization Semaphore. Element used to synchronize multiple :ref:`Thread<class_Thread>`\ s. Initialized to zero on creation. Be careful to avoid deadlocks. For a binary version, see :ref:`Mutex<class_Mutex>`.
  22. Method Descriptions
  23. -------------------
  24. .. _class_Semaphore_method_post:
  25. - :ref:`Error<enum_@GlobalScope_Error>` **post** **(** **)**
  26. Lowers the ``Semaphore``, allowing one more thread in. Returns ``OK`` on success, ``ERR_BUSY`` otherwise.
  27. .. _class_Semaphore_method_wait:
  28. - :ref:`Error<enum_@GlobalScope_Error>` **wait** **(** **)**
  29. Tries to wait for the ``Semaphore``, if its value is zero, blocks until non-zero. Returns ``OK`` on success, ``ERR_BUSY`` otherwise.