class_mutex.rst 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Mutex.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Mutex:
  5. Mutex
  6. =====
  7. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. A synchronization Mutex.
  12. Methods
  13. -------
  14. +----------------------------------------+---------------------------------------------------+
  15. | void | :ref:`lock<class_Mutex_lock>` **(** **)** |
  16. +----------------------------------------+---------------------------------------------------+
  17. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`try_lock<class_Mutex_try_lock>` **(** **)** |
  18. +----------------------------------------+---------------------------------------------------+
  19. | void | :ref:`unlock<class_Mutex_unlock>` **(** **)** |
  20. +----------------------------------------+---------------------------------------------------+
  21. Description
  22. -----------
  23. 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.
  24. Method Descriptions
  25. -------------------
  26. .. _class_Mutex_lock:
  27. - void **lock** **(** **)**
  28. Lock this ``Mutex``, blocks until it is unlocked by the current owner.
  29. .. _class_Mutex_try_lock:
  30. - :ref:`Error<enum_@GlobalScope_Error>` **try_lock** **(** **)**
  31. Try locking this ``Mutex``, does not block. Returns OK on success, ERR_BUSY otherwise.
  32. .. _class_Mutex_unlock:
  33. - void **unlock** **(** **)**
  34. Unlock this ``Mutex``, leaving it to other threads.