class_semaphore.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Semaphore.xml.
  6. .. _class_Semaphore:
  7. Semaphore
  8. =========
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A synchronization semaphore.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 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>`.
  15. .. rst-class:: classref-introduction-group
  16. Tutorials
  17. ---------
  18. - :doc:`Using multiple threads <../tutorials/performance/using_multiple_threads>`
  19. .. rst-class:: classref-reftable-group
  20. Methods
  21. -------
  22. .. table::
  23. :widths: auto
  24. +-------------------------+--------------------------------------------------------------+
  25. | void | :ref:`post<class_Semaphore_method_post>` **(** **)** |
  26. +-------------------------+--------------------------------------------------------------+
  27. | :ref:`bool<class_bool>` | :ref:`try_wait<class_Semaphore_method_try_wait>` **(** **)** |
  28. +-------------------------+--------------------------------------------------------------+
  29. | void | :ref:`wait<class_Semaphore_method_wait>` **(** **)** |
  30. +-------------------------+--------------------------------------------------------------+
  31. .. rst-class:: classref-section-separator
  32. ----
  33. .. rst-class:: classref-descriptions-group
  34. Method Descriptions
  35. -------------------
  36. .. _class_Semaphore_method_post:
  37. .. rst-class:: classref-method
  38. void **post** **(** **)**
  39. Lowers the **Semaphore**, allowing one more thread in.
  40. .. rst-class:: classref-item-separator
  41. ----
  42. .. _class_Semaphore_method_try_wait:
  43. .. rst-class:: classref-method
  44. :ref:`bool<class_bool>` **try_wait** **(** **)**
  45. Like :ref:`wait<class_Semaphore_method_wait>`, but won't block, so if the value is zero, fails immediately and returns ``false``. If non-zero, it returns ``true`` to report success.
  46. .. rst-class:: classref-item-separator
  47. ----
  48. .. _class_Semaphore_method_wait:
  49. .. rst-class:: classref-method
  50. void **wait** **(** **)**
  51. Waits for the **Semaphore**, if its value is zero, blocks until non-zero.
  52. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  53. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  54. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  55. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  56. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  57. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`