Mutex.trylock

Tries to lock mutex. If mutex is already locked by another thread, it immediately returns false. Otherwise it locks mutex and returns true.

#GMutex is neither guaranteed to be recursive nor to be non-recursive. As such, calling glib.mutex.Mutex.lock on a #GMutex that has already been locked by the same thread results in undefined behaviour (including but not limited to deadlocks or arbitrary return values).

class Mutex
bool
trylock
()

Return Value

Type: bool

true if mutex could be locked