class_semaphore.rst 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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/3.5/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.5/doc/classes/Semaphore.xml.
  6. .. _class_Semaphore:
  7. Semaphore
  8. =========
  9. **Inherits:** :ref:`Reference<class_Reference>` **<** :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:`../tutorials/performance/threads/using_multiple_threads`
  19. .. rst-class:: classref-reftable-group
  20. Methods
  21. -------
  22. .. table::
  23. :widths: auto
  24. +---------------------------------------+--------------------------------------------------------------+
  25. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`post<class_Semaphore_method_post>` **(** **)** |
  26. +---------------------------------------+--------------------------------------------------------------+
  27. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`try_wait<class_Semaphore_method_try_wait>` **(** **)** |
  28. +---------------------------------------+--------------------------------------------------------------+
  29. | :ref:`Error<enum_@GlobalScope_Error>` | :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. :ref:`Error<enum_@GlobalScope_Error>` **post** **(** **)**
  39. Lowers the **Semaphore**, allowing one more thread in.
  40. \ **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_@GlobalScope_constant_OK>`.
  41. .. rst-class:: classref-item-separator
  42. ----
  43. .. _class_Semaphore_method_try_wait:
  44. .. rst-class:: classref-method
  45. :ref:`Error<enum_@GlobalScope_Error>` **try_wait** **(** **)**
  46. 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.
  47. .. rst-class:: classref-item-separator
  48. ----
  49. .. _class_Semaphore_method_wait:
  50. .. rst-class:: classref-method
  51. :ref:`Error<enum_@GlobalScope_Error>` **wait** **(** **)**
  52. Waits for the **Semaphore**, if its value is zero, blocks until non-zero.
  53. \ **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_@GlobalScope_constant_OK>`.
  54. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  55. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  56. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  57. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`