.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.

.. _class_Mutex:

Mutex
=====

**Inherits:** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`

**Category:** Core

Brief Description
-----------------

A synchronization Mutex.

Member Functions
----------------

+--------+----------------------------------------------------+
| void   | :ref:`lock<class_Mutex_lock>`  **(** **)**         |
+--------+----------------------------------------------------+
| Error  | :ref:`try_lock<class_Mutex_try_lock>`  **(** **)** |
+--------+----------------------------------------------------+
| void   | :ref:`unlock<class_Mutex_unlock>`  **(** **)**     |
+--------+----------------------------------------------------+

Description
-----------

A synchronization Mutex. Element used in multi-threadding. Basically a binary :ref:`Semaphore<class_semaphore>`. Guarantees that only one thread has this lock, can be used to protect a critical section.

Member Function Description
---------------------------

.. _class_Mutex_lock:

- void  **lock**  **(** **)**

Lock this :ref:`Mutex<class_mutex>`, blocks until it is unlocked by the current owner.

.. _class_Mutex_try_lock:

- Error  **try_lock**  **(** **)**

Try locking this :ref:`Mutex<class_mutex>`, does not block. Returns OK on success else ERR_BUSY.

.. _class_Mutex_unlock:

- void  **unlock**  **(** **)**

Unlock this :ref:`Mutex<class_mutex>`, leaving it to others threads.


