Added g_static_mutex_init to allow initialization of a GStaticMutex, that

2001-02-01  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

	* gthread.c, gthread.h: Added g_static_mutex_init to allow
	initialization of a GStaticMutex, that can not be initialized with
	G_STATIC_MUTEX_INIT, for example in allocated structures.

	* glib/tmpl/threads.sgml, glib/glib-sections.txt: Added
	documentation for g_static_mutex_init().

WCVS: ----------------------------------------------------------------------
This commit is contained in:
Sebastian Wilhelmi
2001-02-01 09:37:28 +00:00
committed by Sebastian Wilhelmi
parent bf2b2fdfca
commit 5434105fcb
15 changed files with 100 additions and 6 deletions

View File

@@ -1,3 +1,8 @@
2001-02-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib/tmpl/threads.sgml, glib/glib-sections.txt: Added
documentation for g_static_mutex_init().
Wed Jan 31 07:14:22 2001 Tim Janik <timj@gtk.org>
* gobject/Makefile.am: adapt to work with new CVS gtk-doc, leaving the old

View File

@@ -461,6 +461,7 @@ g_mutex_free
<SUBSECTION>
GStaticMutex
G_STATIC_MUTEX_INIT
g_static_mutex_init
g_static_mutex_lock
g_static_mutex_trylock
g_static_mutex_unlock

View File

@@ -370,6 +370,12 @@ not use such constructs in your own programs. One working solution is:
#GStaticMutex provides a simpler and safer way of doing this.
</para>
<para>
If you want to use a mutex, but your code should also work without
calling g_thread_init() first, you can not use a #GMutex, as
g_mutex_new() requires that. Use a #GStaticMutex instead.
</para>
<para>
A #GMutex should only be accessed via the following functions.
</para>
@@ -473,10 +479,10 @@ Sometimes you would like to dynamically create a mutex. If you don't
want to require prior calling to g_thread_init(), because your code
should also be usable in non-threaded programs, you are not able to
use g_mutex_new() and thus #GMutex, as that requires a prior call to
g_thread_init(). In theses cases you can also use a #GStaticMutex, but
you should remember to free the #GStaticMutex with
g_static_mutex_free() when not needed anymore to free up any
allocated recourses.
g_thread_init(). In theses cases you can also use a #GStaticMutex. It
must be initialized with g_static_mutex_init() before using it and
freed with with g_static_mutex_free() when not needed anymore to free
up any allocated recourses.
</para>
<para>
@@ -520,8 +526,10 @@ functions.
<!-- ##### MACRO G_STATIC_MUTEX_INIT ##### -->
<para>
Every #GStaticMutex must be initialized with this macro, before it can
be used.
A #GStaticMutex must be initialized with this macro, before it can be
used. This macro can used be to initialize a variable, but it cannot
be assigned to a variable. In that case you have to use
g_static_mutex_init().
</para>
<para>
@@ -535,6 +543,16 @@ GStaticMutex my_mutex = G_STATIC_MUTEX_INIT;
<!-- ##### FUNCTION g_static_mutex_init ##### -->
<para>
A #GStaticMutex must be initialized with this function, before it can
be used. Alternatively you can initialize it with
#G_STATIC_MUTEX_INIT.
</para>
@mutex: a #GStaticMutex to be initialized.
<!-- ##### FUNCTION g_static_mutex_lock ##### -->
<para>
works like g_mutex_lock(), but for a #GStaticMutex.