+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.
+
Wed Jan 31 13:46:58 2001 Owen Taylor <otaylor@redhat.com>
* acinclude.m4 glib-gettext.m4: Fix problem with --disable-nls.
+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.
+
Wed Jan 31 13:46:58 2001 Owen Taylor <otaylor@redhat.com>
* acinclude.m4 glib-gettext.m4: Fix problem with --disable-nls.
+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.
+
Wed Jan 31 13:46:58 2001 Owen Taylor <otaylor@redhat.com>
* acinclude.m4 glib-gettext.m4: Fix problem with --disable-nls.
+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.
+
Wed Jan 31 13:46:58 2001 Owen Taylor <otaylor@redhat.com>
* acinclude.m4 glib-gettext.m4: Fix problem with --disable-nls.
+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.
+
Wed Jan 31 13:46:58 2001 Owen Taylor <otaylor@redhat.com>
* acinclude.m4 glib-gettext.m4: Fix problem with --disable-nls.
+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.
+
Wed Jan 31 13:46:58 2001 Owen Taylor <otaylor@redhat.com>
* acinclude.m4 glib-gettext.m4: Fix problem with --disable-nls.
+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.
+
Wed Jan 31 13:46:58 2001 Owen Taylor <otaylor@redhat.com>
* acinclude.m4 glib-gettext.m4: Fix problem with --disable-nls.
+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.
+
Wed Jan 31 13:46:58 2001 Owen Taylor <otaylor@redhat.com>
* acinclude.m4 glib-gettext.m4: Fix problem with --disable-nls.
+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
<SUBSECTION>
GStaticMutex
G_STATIC_MUTEX_INIT
+g_static_mutex_init
g_static_mutex_lock
g_static_mutex_trylock
g_static_mutex_unlock
</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>
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>
<!-- ##### 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>
+<!-- ##### 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.
return *mutex;
}
+void
+g_static_mutex_init (GStaticMutex *mutex)
+{
+ static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
+
+ g_return_if_fail (mutex);
+
+ memcpy (mutex, &init_mutex, sizeof (GStaticMutex));
+}
+
void
g_static_mutex_free (GStaticMutex* mutex)
{
g_mutex_trylock (g_static_mutex_get_mutex (mutex))
#define g_static_mutex_unlock(mutex) \
g_mutex_unlock (g_static_mutex_get_mutex (mutex))
+void g_static_mutex_init (GStaticMutex *mutex);
void g_static_mutex_free (GStaticMutex *mutex);
struct _GStaticPrivate
return *mutex;
}
+void
+g_static_mutex_init (GStaticMutex *mutex)
+{
+ static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
+
+ g_return_if_fail (mutex);
+
+ memcpy (mutex, &init_mutex, sizeof (GStaticMutex));
+}
+
void
g_static_mutex_free (GStaticMutex* mutex)
{
g_mutex_trylock (g_static_mutex_get_mutex (mutex))
#define g_static_mutex_unlock(mutex) \
g_mutex_unlock (g_static_mutex_get_mutex (mutex))
+void g_static_mutex_init (GStaticMutex *mutex);
void g_static_mutex_free (GStaticMutex *mutex);
struct _GStaticPrivate