Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
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.
- newtype RecMutex = RecMutex (ManagedPtr RecMutex)
- newZeroRecMutex :: MonadIO m => m RecMutex
- noRecMutex :: Maybe RecMutex
- 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
Constructors
RecMutex (ManagedPtr RecMutex) |
Instances
WrappedPtr RecMutex Source # | |
(~) AttrOpTag tag AttrSet => Constructible RecMutex tag Source # | |
((~) * info (ResolveRecMutexMethod t RecMutex), MethodInfo * info RecMutex p) => IsLabel t (RecMutex -> p) Source # | |
((~) * info (ResolveRecMutexMethod t RecMutex), MethodInfo * info RecMutex p) => IsLabelProxy t (RecMutex -> p) Source # | |
HasAttributeList * RecMutex Source # | |
((~) * signature (m ()), MonadIO m) => MethodInfo * RecMutexUnlockMethodInfo RecMutex signature Source # | |
((~) * signature (m Bool), MonadIO m) => MethodInfo * RecMutexTrylockMethodInfo RecMutex signature Source # | |
((~) * signature (m ()), MonadIO m) => MethodInfo * RecMutexLockMethodInfo RecMutex signature Source # | |
((~) * signature (m ()), MonadIO m) => MethodInfo * RecMutexInitMethodInfo RecMutex signature Source # | |
((~) * signature (m ()), MonadIO m) => MethodInfo * RecMutexClearMethodInfo RecMutex signature Source # | |
type AttributeList RecMutex Source # | |
Methods
clear
data RecMutexClearMethodInfo Source #
Instances
((~) * signature (m ()), MonadIO m) => MethodInfo * RecMutexClearMethodInfo RecMutex signature Source # | |
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.
Sine: 2.32
init
data RecMutexInitMethodInfo Source #
Instances
((~) * signature (m ()), MonadIO m) => MethodInfo * RecMutexInitMethodInfo RecMutex signature Source # | |
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) => MethodInfo * RecMutexLockMethodInfo RecMutex signature Source # | |
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) => MethodInfo * RecMutexTrylockMethodInfo RecMutex signature Source # | |
unlock
data RecMutexUnlockMethodInfo Source #
Instances
((~) * signature (m ()), MonadIO m) => MethodInfo * RecMutexUnlockMethodInfo RecMutex signature Source # | |
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