class_mutex.rst 2.0 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 Mutex.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Mutex:
  6. Mutex
  7. =====
  8. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. A synchronization Mutex.
  13. Methods
  14. -------
  15. +---------------------------------------+----------------------------------------------------------+
  16. | void | :ref:`lock<class_Mutex_method_lock>` **(** **)** |
  17. +---------------------------------------+----------------------------------------------------------+
  18. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`try_lock<class_Mutex_method_try_lock>` **(** **)** |
  19. +---------------------------------------+----------------------------------------------------------+
  20. | void | :ref:`unlock<class_Mutex_method_unlock>` **(** **)** |
  21. +---------------------------------------+----------------------------------------------------------+
  22. Description
  23. -----------
  24. A synchronization Mutex. Element used to synchronize multiple :ref:`Thread<class_Thread>`\ s. Basically a binary :ref:`Semaphore<class_Semaphore>`. Guarantees that only one thread can ever acquire this lock at a time. Can be used to protect a critical section. Be careful to avoid deadlocks.
  25. Method Descriptions
  26. -------------------
  27. .. _class_Mutex_method_lock:
  28. - void **lock** **(** **)**
  29. Lock this ``Mutex``, blocks until it is unlocked by the current owner.
  30. ----
  31. .. _class_Mutex_method_try_lock:
  32. - :ref:`Error<enum_@GlobalScope_Error>` **try_lock** **(** **)**
  33. Try locking this ``Mutex``, does not block. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success, :ref:`@GlobalScope.ERR_BUSY<class_@GlobalScope_constant_ERR_BUSY>` otherwise.
  34. ----
  35. .. _class_Mutex_method_unlock:
  36. - void **unlock** **(** **)**
  37. Unlock this ``Mutex``, leaving it to other threads.