GLib.Mutex¶
Details¶
- 
class GLib.Mutex¶
- 
clear()[source]¶
- Frees the resources allocated to a mutex with - GLib.Mutex.init().- This function should not be used with a - GLib.Mutexthat has been statically allocated.- Calling - GLib.Mutex.clear() on a locked mutex leads to undefined behaviour.- Sine: 2.32 
 - 
init()[source]¶
- Initializes a - GLib.Mutexso that it can be used.- This function is useful to initialize a mutex that has been allocated on the stack, or as part of a larger structure. It is not necessary to initialize a mutex that has been statically allocated. - typedef struct { GMutex m; ... } Blob; Blob *b; b = g_new (Blob, 1); g_mutex_init (&b->m); - To undo the effect of - GLib.Mutex.init() when a mutex is no longer needed, use- GLib.Mutex.clear().- Calling - GLib.Mutex.init() on an already initialized- GLib.Mutexleads to undefined behaviour.- New in version 2.32. 
 - 
lock()[source]¶
- Locks self. If self is already locked by another thread, the current thread will block until self is unlocked by the other thread. - GLib.Mutexis neither guaranteed to be recursive nor to be non-recursive. As such, calling- GLib.Mutex.lock() on a- GLib.Mutexthat has already been locked by the same thread results in undefined behaviour (including but not limited to deadlocks).
 - 
trylock()[source]¶
- Returns: - Trueif self could be locked- Return type: - bool- Tries to lock self. If self is already locked by another thread, it immediately returns - False. Otherwise it locks self and returns- True.- GLib.Mutexis neither guaranteed to be recursive nor to be non-recursive. As such, calling- GLib.Mutex.lock() on a- GLib.Mutexthat has already been locked by the same thread results in undefined behaviour (including but not limited to deadlocks or arbitrary return values).
 - 
unlock()[source]¶
- Unlocks self. If another thread is blocked in a - GLib.Mutex.lock() call for self, it will become unblocked and can lock self itself.- Calling - GLib.Mutex.unlock() on a mutex that is not locked by the current thread leads to undefined behaviour.
 
-