Package ch.bailu.gtk.glib
Class RecMutex
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.type.Record
ch.bailu.gtk.glib.RecMutex
- All Implemented Interfaces:
PointerInterface
The GRecMutex struct is an opaque data structure to represent a
recursive mutex. It is similar to a #GMutex 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 #GRecMutex is allocated in static storage then it can be used
without initialisation. Otherwise, you should call
g_rec_mutex_init() on it and g_rec_mutex_clear() when done.
A GRecMutex should only be accessed with the
g_rec_mutex_ functions.
recursive mutex. It is similar to a #GMutex 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 #GRecMutex is allocated in static storage then it can be used
without initialisation. Otherwise, you should call
g_rec_mutex_init() on it and g_rec_mutex_clear() when done.
A GRecMutex should only be accessed with the
g_rec_mutex_ functions.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Frees the resources allocated to a recursive mutex with
g_rec_mutex_init().static ClassHandler
void
init()
Initializes a #GRecMutex so that it can be used.void
lock()
Locks @rec_mutex.boolean
trylock()
Tries to lock @rec_mutex.void
unlock()
Unlocks @rec_mutex.Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
P
- See Also:
-
-
Constructor Details
-
RecMutex
-
-
Method Details
-
getClassHandler
-
getFieldP
-
clear
public void clear()Frees the resources allocated to a recursive mutex with
g_rec_mutex_init().
This function should not be used with a #GRecMutex that has been
statically allocated.
Calling g_rec_mutex_clear() on a locked recursive mutex leads
to undefined behaviour. -
init
public void init()Initializes a #GRecMutex 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.
<!-- language="C" --> typedef struct { GRecMutex m; ... } Blob; Blob *b; b = g_new (Blob, 1); g_rec_mutex_init (&b->m);
Calling g_rec_mutex_init() on an already initialized #GRecMutex
leads to undefined behaviour.
To undo the effect of g_rec_mutex_init() when a recursive mutex
is no longer needed, use g_rec_mutex_clear(). -
lock
public void lock()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. -
trylock
public boolean trylock()Tries to lock @rec_mutex. If @rec_mutex is already locked
by another thread, it immediately returns %FALSE. Otherwise
it locks @rec_mutex and returns %TRUE.- Returns:
- %TRUE if @rec_mutex could be locked
-
unlock
public void unlock()Unlocks @rec_mutex. If another thread is blocked in a
g_rec_mutex_lock() call for @rec_mutex, it will become unblocked
and can lock @rec_mutex itself.
Calling g_rec_mutex_unlock() on a recursive mutex that is not
locked by the current thread leads to undefined behaviour.
-