123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- :github_url: hide
- .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
- .. DO NOT EDIT THIS FILE, but the Mutex.xml source instead.
- .. The source is found in doc/classes or modules/<name>/doc_classes.
- .. _class_Mutex:
- Mutex
- =====
- **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
- **Category:** Core
- Brief Description
- -----------------
- A synchronization mutex (mutual exclusion).
- Methods
- -------
- +---------------------------------------+----------------------------------------------------------+
- | void | :ref:`lock<class_Mutex_method_lock>` **(** **)** |
- +---------------------------------------+----------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`try_lock<class_Mutex_method_try_lock>` **(** **)** |
- +---------------------------------------+----------------------------------------------------------+
- | void | :ref:`unlock<class_Mutex_method_unlock>` **(** **)** |
- +---------------------------------------+----------------------------------------------------------+
- Description
- -----------
- A synchronization mutex (mutual exclusion). This is used to synchronize multiple :ref:`Thread<class_Thread>`\ s, and is equivalent to a binary :ref:`Semaphore<class_Semaphore>`. It guarantees that only one thread can ever acquire the lock at a time. A mutex can be used to protect a critical section; however, be careful to avoid deadlocks.
- Method Descriptions
- -------------------
- .. _class_Mutex_method_lock:
- - void **lock** **(** **)**
- Locks this ``Mutex``, blocks until it is unlocked by the current owner.
- .. _class_Mutex_method_try_lock:
- - :ref:`Error<enum_@GlobalScope_Error>` **try_lock** **(** **)**
- Tries locking this ``Mutex``, but does not block. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success, :ref:`@GlobalScope.ERR_BUSY<class_@GlobalScope_constant_ERR_BUSY>` otherwise.
- .. _class_Mutex_method_unlock:
- - void **unlock** **(** **)**
- Unlocks this ``Mutex``, leaving it to other threads.
|