Package org.gnome.glib
Class StaticRecMutex
java.lang.Object
io.github.jwharm.javagi.base.ProxyInstance
org.gnome.glib.StaticRecMutex
- All Implemented Interfaces:
Proxy
A
GStaticRecMutex
works like a GStaticMutex
, but it can be locked
multiple times by one thread. If you enter it n times, you have to
unlock it n times again to let other threads lock it. An exception
is the function g_static_rec_mutex_unlock_full(): that allows you to
unlock a GStaticRecMutex
completely returning the depth, (i.e. the
number of times this mutex was locked). The depth can later be used
to restore the state of the GStaticRecMutex
by calling
g_static_rec_mutex_lock_full(). In GLib 2.32, GStaticRecMutex
has
been deprecated in favor of GRecMutex
.
Even though GStaticRecMutex
is not opaque, it should only be used
with the following functions.
All of the g_static_rec_mutex_* functions can be used even if
g_thread_init() has not been called. Then they do nothing, apart
from g_static_rec_mutex_trylock(), which does nothing but returning
true
.
-
Constructor Summary
ConstructorDescriptionAllocate a new StaticRecMutex.StaticRecMutex
(Arena arena) Allocate a new StaticRecMutex.StaticRecMutex
(MemorySegment address) Create a StaticRecMutex proxy instance for the provided memory address.StaticRecMutex
(StaticMutex mutex, int depth) Allocate a new StaticRecMutex with the fields set to the provided values.StaticRecMutex
(StaticMutex mutex, int depth, Arena arena) Allocate a new StaticRecMutex with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
free()
Deprecated.Use g_rec_mutex_clear()static MemoryLayout
The memory layout of the native struct.void
init()
Deprecated.Use g_rec_mutex_init()void
lock()
Deprecated.Use g_rec_mutex_lock()void
lockFull
(int depth) Deprecated.Use g_rec_mutex_lock()int
Read the value of the fielddepth
.Read the value of the fieldmutex
.boolean
trylock()
Deprecated.Use g_rec_mutex_trylock()void
unlock()
Deprecated.Use g_rec_mutex_unlock()int
Deprecated.Use g_rec_mutex_unlock()void
writeDepth
(int depth) Write a value in the fielddepth
.void
writeMutex
(StaticMutex mutex) Write a value in the fieldmutex
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
StaticRecMutex
Create a StaticRecMutex proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
StaticRecMutex
Allocate a new StaticRecMutex.- Parameters:
arena
- to control the memory allocation scope
-
StaticRecMutex
public StaticRecMutex()Allocate a new StaticRecMutex. The memory is allocated withArena.ofAuto()
. -
StaticRecMutex
Allocate a new StaticRecMutex with the fields set to the provided values.- Parameters:
mutex
- value for the fieldmutex
depth
- value for the fielddepth
arena
- to control the memory allocation scope
-
StaticRecMutex
Allocate a new StaticRecMutex with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
mutex
- value for the fieldmutex
depth
- value for the fielddepth
-
-
Method Details
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readMutex
Read the value of the fieldmutex
.- Returns:
- The value of the field
mutex
-
writeMutex
Write a value in the fieldmutex
.- Parameters:
mutex
- The new value for the fieldmutex
-
readDepth
public int readDepth()Read the value of the fielddepth
.- Returns:
- The value of the field
depth
-
writeDepth
public void writeDepth(int depth) Write a value in the fielddepth
.- Parameters:
depth
- The new value for the fielddepth
-
free
Deprecated.Use g_rec_mutex_clear()Releases all resources allocated to aGStaticRecMutex
.You don't have to call this functions for a
GStaticRecMutex
with an unbounded lifetime, i.e. objects declared 'static', but if you have aGStaticRecMutex
as a member of a structure and the structure is freed, you should also free theGStaticRecMutex
. -
init
Deprecated.Use g_rec_mutex_init()AGStaticRecMutex
must be initialized with this function before it can be used. Alternatively you can initialize it withG_STATIC_REC_MUTEX_INIT
. -
lock
Deprecated.Use g_rec_mutex_lock()Locks this StaticRecMutex. If this StaticRecMutex is already locked by another thread, the current thread will block until this StaticRecMutex is unlocked by the other thread. If this StaticRecMutex is already locked by the calling thread, this functions increases the depth of this StaticRecMutex and returns immediately. -
lockFull
Deprecated.Use g_rec_mutex_lock()Works like calling g_static_rec_mutex_lock() for this StaticRecMutexdepth
times.- Parameters:
depth
- number of times this mutex has to be unlocked to be completely unlocked.
-
trylock
Deprecated.Use g_rec_mutex_trylock()Tries to lock this StaticRecMutex. If this StaticRecMutex is already locked by another thread, it immediately returnsfalse
. Otherwise it locks this StaticRecMutex and returnstrue
. If this StaticRecMutex is already locked by the calling thread, this functions increases the depth of this StaticRecMutex and immediately returnstrue
.- Returns:
true
, if this StaticRecMutex could be locked.
-
unlock
Deprecated.Use g_rec_mutex_unlock()Unlocks this StaticRecMutex. Another thread will be allowed to lock this StaticRecMutex only when it has been unlocked as many times as it had been locked before. If this StaticRecMutex is completely unlocked and another thread is blocked in a g_static_rec_mutex_lock() call for this StaticRecMutex, it will be woken and can lock this StaticRecMutex itself. -
unlockFull
Deprecated.Use g_rec_mutex_unlock()Completely unlocks this StaticRecMutex. If another thread is blocked in a g_static_rec_mutex_lock() call for this StaticRecMutex, it will be woken and can lock this StaticRecMutex itself. This function returns the number of times that this StaticRecMutex has been locked by the current thread. To restore the state before the call to g_static_rec_mutex_unlock_full() you can call g_static_rec_mutex_lock_full() with the depth returned by this function.- Returns:
- number of times this StaticRecMutex has been locked by the current thread.
-