class_semaphore.rst 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Semaphore.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Semaphore:
  6. Semaphore
  7. =========
  8. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. A synchronization semaphore.
  10. Description
  11. -----------
  12. A synchronization semaphore which can be 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>`.
  13. Tutorials
  14. ---------
  15. - :doc:`../tutorials/performance/threads/using_multiple_threads`
  16. Methods
  17. -------
  18. +---------------------------------------+------------------------------------------------------+
  19. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`post<class_Semaphore_method_post>` **(** **)** |
  20. +---------------------------------------+------------------------------------------------------+
  21. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`wait<class_Semaphore_method_wait>` **(** **)** |
  22. +---------------------------------------+------------------------------------------------------+
  23. Method Descriptions
  24. -------------------
  25. .. _class_Semaphore_method_post:
  26. - :ref:`Error<enum_@GlobalScope_Error>` **post** **(** **)**
  27. Lowers the ``Semaphore``, allowing one more thread in. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success, :ref:`@GlobalScope.ERR_BUSY<class_@GlobalScope_constant_ERR_BUSY>` otherwise.
  28. ----
  29. .. _class_Semaphore_method_wait:
  30. - :ref:`Error<enum_@GlobalScope_Error>` **wait** **(** **)**
  31. Tries to wait for the ``Semaphore``, if its value is zero, blocks until non-zero. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success, :ref:`@GlobalScope.ERR_BUSY<class_@GlobalScope_constant_ERR_BUSY>` otherwise.
  32. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  33. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  34. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`