| Copyright | Will Thompson and Iñaki García Etxebarria |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | None |
| Language | Haskell2010 |
GI.GLib.Structs.RecMutex
Description
The GRecMutex struct is an opaque data structure to represent a
recursive mutex. It is similar to a Mutex with the difference
that it is possible to lock a GRecMutex multiple times in the same
thread without deadlock. When doing so, care has to be taken to
unlock the recursive mutex as often as it has been locked.
If a RecMutex is allocated in static storage then it can be used
without initialisation. Otherwise, you should call
recMutexInit on it and recMutexClear when done.
A GRecMutex should only be accessed with the g_rec_mutex_ functions.
Since: 2.32
Synopsis
- newtype RecMutex = RecMutex (ManagedPtr RecMutex)
- newZeroRecMutex :: MonadIO m => m RecMutex
- type family ResolveRecMutexMethod (t :: Symbol) o where ...
- data RecMutexClearMethodInfo
- recMutexClear :: (HasCallStack, MonadIO m) => RecMutex -> m ()
- data RecMutexInitMethodInfo
- recMutexInit :: (HasCallStack, MonadIO m) => RecMutex -> m ()
- data RecMutexLockMethodInfo
- recMutexLock :: (HasCallStack, MonadIO m) => RecMutex -> m ()
- data RecMutexTrylockMethodInfo
- recMutexTrylock :: (HasCallStack, MonadIO m) => RecMutex -> m Bool
- data RecMutexUnlockMethodInfo
- recMutexUnlock :: (HasCallStack, MonadIO m) => RecMutex -> m ()
Exported types
Memory-managed wrapper type.
Constructors
| RecMutex (ManagedPtr RecMutex) |
Instances
Methods
Click to display all available methods, including inherited ones
type family ResolveRecMutexMethod (t :: Symbol) o where ... Source #
Equations
| ResolveRecMutexMethod "clear" o = RecMutexClearMethodInfo | |
| ResolveRecMutexMethod "init" o = RecMutexInitMethodInfo | |
| ResolveRecMutexMethod "lock" o = RecMutexLockMethodInfo | |
| ResolveRecMutexMethod "trylock" o = RecMutexTrylockMethodInfo | |
| ResolveRecMutexMethod "unlock" o = RecMutexUnlockMethodInfo | |
| ResolveRecMutexMethod l o = MethodResolutionFailed l o :: Type |
clear
data RecMutexClearMethodInfo Source #
Instances
| (signature ~ m (), MonadIO m) => OverloadedMethod RecMutexClearMethodInfo RecMutex signature Source # | |
Defined in GI.GLib.Structs.RecMutex Methods overloadedMethod :: RecMutex -> signature # | |
| OverloadedMethodInfo RecMutexClearMethodInfo RecMutex Source # | |
Defined in GI.GLib.Structs.RecMutex Methods | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => RecMutex |
|
| -> m () |
Frees the resources allocated to a recursive mutex with
recMutexInit.
This function should not be used with a RecMutex that has been
statically allocated.
Calling recMutexClear on a locked recursive mutex leads
to undefined behaviour.
Since: 2.32
init
data RecMutexInitMethodInfo Source #
Instances
| (signature ~ m (), MonadIO m) => OverloadedMethod RecMutexInitMethodInfo RecMutex signature Source # | |
Defined in GI.GLib.Structs.RecMutex Methods overloadedMethod :: RecMutex -> signature # | |
| OverloadedMethodInfo RecMutexInitMethodInfo RecMutex Source # | |
Defined in GI.GLib.Structs.RecMutex Methods | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => RecMutex |
|
| -> m () |
Initializes a 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.
C code
typedef struct {
GRecMutex m;
...
} Blob;
Blob *b;
b = g_new (Blob, 1);
g_rec_mutex_init (&b->m);Calling recMutexInit on an already initialized RecMutex
leads to undefined behaviour.
To undo the effect of recMutexInit when a recursive mutex
is no longer needed, use recMutexClear.
Since: 2.32
lock
data RecMutexLockMethodInfo Source #
Instances
| (signature ~ m (), MonadIO m) => OverloadedMethod RecMutexLockMethodInfo RecMutex signature Source # | |
Defined in GI.GLib.Structs.RecMutex Methods overloadedMethod :: RecMutex -> signature # | |
| OverloadedMethodInfo RecMutexLockMethodInfo RecMutex Source # | |
Defined in GI.GLib.Structs.RecMutex Methods | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => RecMutex |
|
| -> m () |
Locks recMutex. If recMutex is already locked by another
thread, the current thread will block until recMutex is
unlocked by the other thread. If recMutex is already locked
by the current thread, the 'lock count' of recMutex is increased.
The mutex will only become available again when it is unlocked
as many times as it has been locked.
Since: 2.32
trylock
data RecMutexTrylockMethodInfo Source #
Instances
| (signature ~ m Bool, MonadIO m) => OverloadedMethod RecMutexTrylockMethodInfo RecMutex signature Source # | |
Defined in GI.GLib.Structs.RecMutex Methods overloadedMethod :: RecMutex -> signature # | |
| OverloadedMethodInfo RecMutexTrylockMethodInfo RecMutex Source # | |
Defined in GI.GLib.Structs.RecMutex Methods | |
unlock
data RecMutexUnlockMethodInfo Source #
Instances
| (signature ~ m (), MonadIO m) => OverloadedMethod RecMutexUnlockMethodInfo RecMutex signature Source # | |
Defined in GI.GLib.Structs.RecMutex Methods overloadedMethod :: RecMutex -> signature # | |
| OverloadedMethodInfo RecMutexUnlockMethodInfo RecMutex Source # | |
Defined in GI.GLib.Structs.RecMutex Methods | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => RecMutex |
|
| -> m () |
Unlocks recMutex. If another thread is blocked in a
recMutexLock call for recMutex, it will become unblocked
and can lock recMutex itself.
Calling recMutexUnlock on a recursive mutex that is not
locked by the current thread leads to undefined behaviour.
Since: 2.32