class_semaphore.rst 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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:`RefCounted<class_RefCounted>` **<** :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:`Using multiple threads <../tutorials/performance/using_multiple_threads>`
  16. Methods
  17. -------
  18. +---------------------------------------+--------------------------------------------------------------+
  19. | void | :ref:`post<class_Semaphore_method_post>` **(** **)** |
  20. +---------------------------------------+--------------------------------------------------------------+
  21. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`try_wait<class_Semaphore_method_try_wait>` **(** **)** |
  22. +---------------------------------------+--------------------------------------------------------------+
  23. | void | :ref:`wait<class_Semaphore_method_wait>` **(** **)** |
  24. +---------------------------------------+--------------------------------------------------------------+
  25. Method Descriptions
  26. -------------------
  27. .. _class_Semaphore_method_post:
  28. - void **post** **(** **)**
  29. Lowers the ``Semaphore``, allowing one more thread in.
  30. ----
  31. .. _class_Semaphore_method_try_wait:
  32. - :ref:`Error<enum_@GlobalScope_Error>` **try_wait** **(** **)**
  33. Like :ref:`wait<class_Semaphore_method_wait>`, but won't block, so if the value is zero, fails immediately and returns :ref:`@GlobalScope.ERR_BUSY<class_@GlobalScope_constant_ERR_BUSY>`. If non-zero, it returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` to report success.
  34. ----
  35. .. _class_Semaphore_method_wait:
  36. - void **wait** **(** **)**
  37. Waits for the ``Semaphore``, if its value is zero, blocks until non-zero.
  38. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  39. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  40. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  41. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  42. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  43. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`