class_semaphore.rst 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. **Category:** Core
  10. Brief Description
  11. -----------------
  12. A synchronization Semaphore.
  13. Methods
  14. -------
  15. +---------------------------------------+------------------------------------------------------+
  16. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`post<class_Semaphore_method_post>` **(** **)** |
  17. +---------------------------------------+------------------------------------------------------+
  18. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`wait<class_Semaphore_method_wait>` **(** **)** |
  19. +---------------------------------------+------------------------------------------------------+
  20. Description
  21. -----------
  22. A synchronization Semaphore. Element 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>`.
  23. Method Descriptions
  24. -------------------
  25. .. _class_Semaphore_method_post:
  26. - :ref:`Error<enum_@GlobalScope_Error>` **post** **(** **)**
  27. Lowers the ``Semaphore``, allowing one more thread in. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success, :ref:`@GlobalScope.ERR_BUSY<class_@GlobalScope_constant_ERR_BUSY>` otherwise.
  28. ----
  29. .. _class_Semaphore_method_wait:
  30. - :ref:`Error<enum_@GlobalScope_Error>` **wait** **(** **)**
  31. Tries to wait for the ``Semaphore``, if its value is zero, blocks until non-zero. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success, :ref:`@GlobalScope.ERR_BUSY<class_@GlobalScope_constant_ERR_BUSY>` otherwise.