class_semaphore.rst 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.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/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.