class_mutex.rst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. Member Functions
  13. ----------------
  14. +------------------------+---------------------------------------------------+
  15. | void | :ref:`lock<class_Mutex_lock>` **(** **)** |
  16. +------------------------+---------------------------------------------------+
  17. | :ref:`int<class_int>` | :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. Member Function Description
  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:`int<class_int>` **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.