class_semaphore.rst 2.9 KB

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