:right-sidebar: True RecMutex =================================================================== .. currentmodule:: gi.repository.GLib .. versionadded:: 2.32 .. class:: RecMutex(*args, **kwargs) :no-contents-entry: :Constructors: :: RecMutex() Methods ------- .. rst-class:: interim-class .. class:: RecMutex :no-index: .. method:: clear() -> None Frees the resources allocated to a recursive mutex with :func:`~gi.repository.GLib.RecMutex.init`. This function should not be used with a :obj:`~gi.repository.GLib.RecMutex` that has been statically allocated. Calling :func:`~gi.repository.GLib.RecMutex.clear` on a locked recursive mutex leads to undefined behaviour. .. versionadded:: 2.32 .. method:: init() -> None Initializes a :obj:`~gi.repository.GLib.RecMutex` so that it can be used. This function is useful to initialize a recursive mutex that has been allocated on the stack, or as part of a larger structure. It is not necessary to initialise a recursive mutex that has been statically allocated. .. code-block:: C :dedent: typedef struct { GRecMutex m; ... } Blob; Blob *b; b = g_new (Blob, 1); g_rec_mutex_init (&b->m); Calling :func:`~gi.repository.GLib.RecMutex.init` on an already initialized :obj:`~gi.repository.GLib.RecMutex` leads to undefined behaviour. To undo the effect of :func:`~gi.repository.GLib.RecMutex.init` when a recursive mutex is no longer needed, use :func:`~gi.repository.GLib.RecMutex.clear`. .. versionadded:: 2.32 .. method:: lock() -> None Locks ``rec_mutex``. If ``rec_mutex`` is already locked by another thread, the current thread will block until ``rec_mutex`` is unlocked by the other thread. If ``rec_mutex`` is already locked by the current thread, the 'lock count' of ``rec_mutex`` is increased. The mutex will only become available again when it is unlocked as many times as it has been locked. .. versionadded:: 2.32 .. method:: trylock() -> bool Tries to lock ``rec_mutex``. If ``rec_mutex`` is already locked by another thread, it immediately returns :const:`False`. Otherwise it locks ``rec_mutex`` and returns :const:`True`. .. versionadded:: 2.32 .. method:: unlock() -> None Unlocks ``rec_mutex``. If another thread is blocked in a :func:`~gi.repository.GLib.RecMutex.lock` call for ``rec_mutex``, it will become unblocked and can lock ``rec_mutex`` itself. Calling :func:`~gi.repository.GLib.RecMutex.unlock` on a recursive mutex that is not locked by the current thread leads to undefined behaviour. .. versionadded:: 2.32 Fields ------ .. rst-class:: interim-class .. class:: RecMutex :no-index: .. attribute:: i .. attribute:: p