<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC '-//OASIS//DTD DocBook XML V4.5//EN'
                      'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd' [
<!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="glib-Deprecated-Thread-APIs">
<refmeta>
<refentrytitle role="top_of_page" id="glib-Deprecated-Thread-APIs.top_of_page">Deprecated thread API</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GLIB Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Deprecated thread API</refname>
<refpurpose>old thread APIs (for reference only)</refpurpose>
</refnamediv>

<refsect1 id="glib-Deprecated-Thread-APIs.functions" role="functions_proto">
<title role="functions_proto.title">Functions</title>
<informaltable pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="functions_proto_type" colwidth="150px"/>
<colspec colname="functions_proto_name"/>
<tbody>
<row><entry role="function_type"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-thread-supported">g_thread_supported</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

<row><entry role="function_type"><link linkend="GThread"><returnvalue>GThread</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-thread-create">g_thread_create</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GThread"><returnvalue>GThread</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-thread-create-full">g_thread_create_full</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-thread-set-priority">g_thread_set_priority</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-thread-foreach">g_thread_foreach</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

<row><entry role="function_type"><link linkend="GMutex"><returnvalue>GMutex</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-mutex-new">g_mutex_new</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-mutex-free">g_mutex_free</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GCond"><returnvalue>GCond</returnvalue></link>*
</entry><entry role="function_name"><link linkend="g-cond-new">g_cond_new</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-cond-free">g_cond_free</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-static-mutex-init">g_static_mutex_init</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-static-mutex-lock">g_static_mutex_lock</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-static-mutex-trylock">g_static_mutex_trylock</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-static-mutex-unlock">g_static_mutex_unlock</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GMutex"><returnvalue>GMutex</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-static-mutex-get-mutex">g_static_mutex_get_mutex</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-static-mutex-free">g_static_mutex_free</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="glib-Deprecated-Thread-APIs.other" role="other_proto">
<title role="other_proto.title">Types and Values</title>
<informaltable pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="other_proto_type" colwidth="150px"/>
<colspec colname="other_proto_name"/>
<tbody>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-THREADS-IMPL-POSIX:CAPS">G_THREADS_IMPL_POSIX</link></entry></row>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-THREADS-IMPL-WIN32:CAPS">G_THREADS_IMPL_WIN32</link></entry></row>




<row><entry role="datatype_keyword"></entry><entry role="function_name"><link linkend="GStaticMutex">GStaticMutex</link></entry></row>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-STATIC-MUTEX-INIT:CAPS">G_STATIC_MUTEX_INIT</link></entry></row>



<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-STATIC-PRIVATE-INIT:CAPS">G_STATIC_PRIVATE_INIT</link></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>

<refsect1 id="glib-Deprecated-Thread-APIs.includes"><title>Includes</title><synopsis>#include &lt;glib.h&gt;
</synopsis></refsect1>

<refsect1 id="glib-Deprecated-Thread-APIs.description" role="desc">
<title role="desc.title">Description</title>
<para>These APIs are deprecated.  You should not use them in new code.
This section remains only to assist with understanding code that was
written to use these APIs at some point in the past.</para>

</refsect1>
<refsect1 id="glib-Deprecated-Thread-APIs.functions_details" role="details">
<title role="details.title">Functions</title>
<refsect2 id="g-thread-supported" role="function">
<title>g_thread_supported&#160;()</title>
<indexterm zone="g-thread-supported"><primary sortas="thread_supported">g_thread_supported</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
g_thread_supported ();</programlisting>
<para>This macro returns <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if the thread system is initialized,
and <link linkend="FALSE:CAPS"><literal>FALSE</literal></link> if it is not.</para>
<para>For language bindings, <link linkend="g-thread-get-initialized"><function>g_thread_get_initialized()</function></link> provides
the same functionality as a function.</para>
<refsect3 id="g-thread-supported.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link>, if the thread system is initialized</para>
</refsect3></refsect2>
<refsect2 id="g-thread-create" role="function" condition="deprecated:2.32: Use g_thread_new() instead">
<title>g_thread_create&#160;()</title>
<indexterm zone="g-thread-create" role="deprecated"><primary sortas="thread_create">g_thread_create</primary></indexterm>
<programlisting language="C"><link linkend="GThread"><returnvalue>GThread</returnvalue></link>&#160;*
g_thread_create (<parameter><link linkend="GThreadFunc"><type>GThreadFunc</type></link> func</parameter>,
                 <parameter><link linkend="gpointer"><type>gpointer</type></link> data</parameter>,
                 <parameter><link linkend="gboolean"><type>gboolean</type></link> joinable</parameter>,
                 <parameter><link linkend="GError"><type>GError</type></link> **error</parameter>);</programlisting>
<warning><para><literal>g_thread_create</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>Use <link linkend="g-thread-new"><function>g_thread_new()</function></link> instead</para>
</warning>
<para>This function creates a new thread.</para>
<para>The new thread executes the function <parameter>func</parameter>
 with the argument <parameter>data</parameter>
.
If the thread was created successfully, it is returned.</para>
<para><parameter>error</parameter>
 can be <link linkend="NULL:CAPS"><literal>NULL</literal></link> to ignore errors, or non-<link linkend="NULL:CAPS"><literal>NULL</literal></link> to report errors.
The error is set, if and only if the function returns <link linkend="NULL:CAPS"><literal>NULL</literal></link>.</para>
<para>This function returns a reference to the created thread only if
<parameter>joinable</parameter>
 is <link linkend="TRUE:CAPS"><literal>TRUE</literal></link>.  In that case, you must free this reference by
calling <link linkend="g-thread-unref"><function>g_thread_unref()</function></link> or <link linkend="g-thread-join"><function>g_thread_join()</function></link>.  If <parameter>joinable</parameter>
 is <link linkend="FALSE:CAPS"><literal>FALSE</literal></link>
then you should probably not touch the return value.</para>
<refsect3 id="g-thread-create.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>func</para></entry>
<entry role="parameter_description"><para>a function to execute in the new thread</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>data</para></entry>
<entry role="parameter_description"><para>an argument to supply to the new thread</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>joinable</para></entry>
<entry role="parameter_description"><para>should this thread be joinable?</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>error</para></entry>
<entry role="parameter_description"><para>return location for error, or <link linkend="NULL:CAPS"><literal>NULL</literal></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-thread-create.returns" role="returns">
<title>Returns</title>
<para> the new <link linkend="GThread"><type>GThread</type></link> on success</para>
</refsect3></refsect2>
<refsect2 id="g-thread-create-full" role="function" condition="deprecated">
<title>g_thread_create_full&#160;()</title>
<indexterm zone="g-thread-create-full" role="deprecated"><primary sortas="thread_create_full">g_thread_create_full</primary></indexterm>
<programlisting language="C"><link linkend="GThread"><returnvalue>GThread</returnvalue></link>&#160;*
g_thread_create_full (<parameter><link linkend="GThreadFunc"><type>GThreadFunc</type></link> func</parameter>,
                      <parameter><link linkend="gpointer"><type>gpointer</type></link> data</parameter>,
                      <parameter><link linkend="gulong"><type>gulong</type></link> stack_size</parameter>,
                      <parameter><link linkend="gboolean"><type>gboolean</type></link> joinable</parameter>,
                      <parameter><link linkend="gboolean"><type>gboolean</type></link> bound</parameter>,
                      <parameter><link linkend="GThreadPriority"><type>GThreadPriority</type></link> priority</parameter>,
                      <parameter><link linkend="GError"><type>GError</type></link> **error</parameter>);</programlisting>
<warning><para><literal>g_thread_create_full</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>The <parameter>bound</parameter>
 and <parameter>priority</parameter>
 arguments are now ignored.
Use <link linkend="g-thread-new"><function>g_thread_new()</function></link>.</para>
</warning>
<para>This function creates a new thread.</para>
<refsect3 id="g-thread-create-full.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>func</para></entry>
<entry role="parameter_description"><para>a function to execute in the new thread.</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>data</para></entry>
<entry role="parameter_description"><para>an argument to supply to the new thread.</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>stack_size</para></entry>
<entry role="parameter_description"><para>a stack size for the new thread.</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>joinable</para></entry>
<entry role="parameter_description"><para>should this thread be joinable?</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>bound</para></entry>
<entry role="parameter_description"><para>ignored</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>priority</para></entry>
<entry role="parameter_description"><para>ignored</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>error</para></entry>
<entry role="parameter_description"><para>return location for error.</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-thread-create-full.returns" role="returns">
<title>Returns</title>
<para> the new <link linkend="GThread"><type>GThread</type></link> on success.</para>
</refsect3></refsect2>
<refsect2 id="g-thread-set-priority" role="function" condition="deprecated:2.32: Thread priorities no longer have any effect.">
<title>g_thread_set_priority&#160;()</title>
<indexterm zone="g-thread-set-priority" role="deprecated"><primary sortas="thread_set_priority">g_thread_set_priority</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_thread_set_priority (<parameter><link linkend="GThread"><type>GThread</type></link> *thread</parameter>,
                       <parameter><link linkend="GThreadPriority"><type>GThreadPriority</type></link> priority</parameter>);</programlisting>
<warning><para><literal>g_thread_set_priority</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>Thread priorities no longer have any effect.</para>
</warning>
<para>This function does nothing.</para>
<refsect3 id="g-thread-set-priority.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>thread</para></entry>
<entry role="parameter_description"><para>a <link linkend="GThread"><type>GThread</type></link>.</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>priority</para></entry>
<entry role="parameter_description"><para>ignored</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="g-thread-foreach" role="function" condition="deprecated|since:2.10">
<title>g_thread_foreach&#160;()</title>
<indexterm zone="g-thread-foreach" role="deprecated"><primary sortas="thread_foreach">g_thread_foreach</primary></indexterm><indexterm zone="g-thread-foreach" role="2.10"><primary sortas="thread_foreach">g_thread_foreach</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_thread_foreach (<parameter><link linkend="GFunc"><type>GFunc</type></link> thread_func</parameter>,
                  <parameter><link linkend="gpointer"><type>gpointer</type></link> user_data</parameter>);</programlisting>
<warning><para><literal>g_thread_foreach</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>There aren't many things you can do with a <link linkend="GThread"><type>GThread</type></link>,
    except comparing it with one that was returned from <link linkend="g-thread-create"><function>g_thread_create()</function></link>.
    There are better ways to find out if your thread is still alive.</para>
</warning>
<para>Call <parameter>thread_func</parameter>
 on all <link linkend="GThreads"><type>GThreads</type></link> that have been
created with <link linkend="g-thread-create"><function>g_thread_create()</function></link>.</para>
<para>Note that threads may decide to exit while <parameter>thread_func</parameter>
 is
running, so without intimate knowledge about the lifetime of
foreign threads, <parameter>thread_func</parameter>
 shouldn't access the GThread*
pointer passed in as first argument. However, <parameter>thread_func</parameter>
 will
not be called for threads which are known to have exited already.</para>
<para>Due to thread lifetime checks, this function has an execution complexity
which is quadratic in the number of existing threads.</para>
<refsect3 id="g-thread-foreach.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>thread_func</para></entry>
<entry role="parameter_description"><para>function to call for all <link linkend="GThread"><type>GThread</type></link> structures</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>user_data</para></entry>
<entry role="parameter_description"><para>second argument to <parameter>thread_func</parameter>
</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><para role="since">Since: <link linkend="api-index-2.10">2.10</link></para></refsect2>
<refsect2 id="g-mutex-new" role="function" condition="deprecated">
<title>g_mutex_new&#160;()</title>
<indexterm zone="g-mutex-new" role="deprecated"><primary sortas="mutex_new">g_mutex_new</primary></indexterm>
<programlisting language="C"><link linkend="GMutex"><returnvalue>GMutex</returnvalue></link>&#160;*
g_mutex_new ();</programlisting>
<warning><para><literal>g_mutex_new</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>GMutex can now be statically allocated, or embedded
in structures and initialised with <link linkend="g-mutex-init"><function>g_mutex_init()</function></link>.</para>
</warning>
<para>Allocates and initializes a new <link linkend="GMutex"><type>GMutex</type></link>.</para>
<refsect3 id="g-mutex-new.returns" role="returns">
<title>Returns</title>
<para> a newly allocated <link linkend="GMutex"><type>GMutex</type></link>. Use <link linkend="g-mutex-free"><function>g_mutex_free()</function></link> to free</para>
</refsect3></refsect2>
<refsect2 id="g-mutex-free" role="function" condition="deprecated">
<title>g_mutex_free&#160;()</title>
<indexterm zone="g-mutex-free" role="deprecated"><primary sortas="mutex_free">g_mutex_free</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_mutex_free (<parameter><link linkend="GMutex"><type>GMutex</type></link> *mutex</parameter>);</programlisting>
<warning><para><literal>g_mutex_free</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>GMutex can now be statically allocated, or embedded
in structures and initialised with <link linkend="g-mutex-init"><function>g_mutex_init()</function></link>.</para>
</warning>
<para>Destroys a <parameter>mutex</parameter>
 that has been created with <link linkend="g-mutex-new"><function>g_mutex_new()</function></link>.</para>
<para>Calling <link linkend="g-mutex-free"><function>g_mutex_free()</function></link> on a locked mutex may result
in undefined behaviour.</para>
<refsect3 id="g-mutex-free.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>mutex</para></entry>
<entry role="parameter_description"><para>a <link linkend="GMutex"><type>GMutex</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="g-cond-new" role="function" condition="deprecated">
<title>g_cond_new&#160;()</title>
<indexterm zone="g-cond-new" role="deprecated"><primary sortas="cond_new">g_cond_new</primary></indexterm>
<programlisting language="C"><link linkend="GCond"><returnvalue>GCond</returnvalue></link>*
g_cond_new ();</programlisting>
<warning><para><literal>g_cond_new</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>GCond can now be statically allocated, or embedded
in structures and initialised with <link linkend="g-cond-init"><function>g_cond_init()</function></link>.</para>
</warning>
<para>Allocates and initializes a new <link linkend="GCond"><type>GCond</type></link>.</para>
<refsect3 id="g-cond-new.returns" role="returns">
<title>Returns</title>
<para> a newly allocated <link linkend="GCond"><type>GCond</type></link>. Free with <link linkend="g-cond-free"><function>g_cond_free()</function></link></para>
</refsect3></refsect2>
<refsect2 id="g-cond-free" role="function" condition="deprecated">
<title>g_cond_free&#160;()</title>
<indexterm zone="g-cond-free" role="deprecated"><primary sortas="cond_free">g_cond_free</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_cond_free (<parameter><link linkend="GCond"><type>GCond</type></link> *cond</parameter>);</programlisting>
<warning><para><literal>g_cond_free</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>GCond can now be statically allocated, or embedded
in structures and initialised with <link linkend="g-cond-init"><function>g_cond_init()</function></link>.</para>
</warning>
<para>Destroys a <link linkend="GCond"><type>GCond</type></link> that has been created with <link linkend="g-cond-new"><function>g_cond_new()</function></link>.</para>
<para>Calling <link linkend="g-cond-free"><function>g_cond_free()</function></link> for a <link linkend="GCond"><type>GCond</type></link> on which threads are
blocking leads to undefined behaviour.</para>
<refsect3 id="g-cond-free.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>cond</para></entry>
<entry role="parameter_description"><para>a <link linkend="GCond"><type>GCond</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="g-static-mutex-init" role="function" condition="deprecated:2.32: Use g_mutex_init()">
<title>g_static_mutex_init&#160;()</title>
<indexterm zone="g-static-mutex-init" role="deprecated"><primary sortas="static_mutex_init">g_static_mutex_init</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_static_mutex_init (<parameter><link linkend="GStaticMutex"><type>GStaticMutex</type></link> *mutex</parameter>);</programlisting>
<warning><para><literal>g_static_mutex_init</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>Use <link linkend="g-mutex-init"><function>g_mutex_init()</function></link></para>
</warning>
<para>Initializes <parameter>mutex</parameter>
.
Alternatively you can initialize it with <link linkend="G-STATIC-MUTEX-INIT:CAPS"><type>G_STATIC_MUTEX_INIT</type></link>.</para>
<refsect3 id="g-static-mutex-init.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>mutex</para></entry>
<entry role="parameter_description"><para>a <link linkend="GStaticMutex"><type>GStaticMutex</type></link> to be initialized.</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="g-static-mutex-lock" role="function" condition="deprecated:2.32: Use g_mutex_lock()">
<title>g_static_mutex_lock&#160;()</title>
<indexterm zone="g-static-mutex-lock" role="deprecated"><primary sortas="static_mutex_lock">g_static_mutex_lock</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_static_mutex_lock (<parameter><link linkend="GStaticMutex"><type>GStaticMutex</type></link> *mutex</parameter>);</programlisting>
<warning><para><literal>g_static_mutex_lock</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>Use <link linkend="g-mutex-lock"><function>g_mutex_lock()</function></link></para>
</warning>
<para>Works like <link linkend="g-mutex-lock"><function>g_mutex_lock()</function></link>, but for a <link linkend="GStaticMutex"><type>GStaticMutex</type></link>.</para>
<refsect3 id="g-static-mutex-lock.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>mutex</para></entry>
<entry role="parameter_description"><para>a <link linkend="GStaticMutex"><type>GStaticMutex</type></link>.</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="g-static-mutex-trylock" role="function" condition="deprecated:2.32: Use g_mutex_trylock()">
<title>g_static_mutex_trylock&#160;()</title>
<indexterm zone="g-static-mutex-trylock" role="deprecated"><primary sortas="static_mutex_trylock">g_static_mutex_trylock</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
g_static_mutex_trylock (<parameter><link linkend="GStaticMutex"><type>GStaticMutex</type></link> *mutex</parameter>);</programlisting>
<warning><para><literal>g_static_mutex_trylock</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>Use <link linkend="g-mutex-trylock"><function>g_mutex_trylock()</function></link></para>
</warning>
<para>Works like <link linkend="g-mutex-trylock"><function>g_mutex_trylock()</function></link>, but for a <link linkend="GStaticMutex"><type>GStaticMutex</type></link>.</para>
<refsect3 id="g-static-mutex-trylock.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>mutex</para></entry>
<entry role="parameter_description"><para>a <link linkend="GStaticMutex"><type>GStaticMutex</type></link>.</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-static-mutex-trylock.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link>, if the <link linkend="GStaticMutex"><type>GStaticMutex</type></link> could be locked.</para>
</refsect3></refsect2>
<refsect2 id="g-static-mutex-unlock" role="function" condition="deprecated:2.32: Use g_mutex_unlock()">
<title>g_static_mutex_unlock&#160;()</title>
<indexterm zone="g-static-mutex-unlock" role="deprecated"><primary sortas="static_mutex_unlock">g_static_mutex_unlock</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_static_mutex_unlock (<parameter><link linkend="GStaticMutex"><type>GStaticMutex</type></link> *mutex</parameter>);</programlisting>
<warning><para><literal>g_static_mutex_unlock</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>Use <link linkend="g-mutex-unlock"><function>g_mutex_unlock()</function></link></para>
</warning>
<para>Works like <link linkend="g-mutex-unlock"><function>g_mutex_unlock()</function></link>, but for a <link linkend="GStaticMutex"><type>GStaticMutex</type></link>.</para>
<refsect3 id="g-static-mutex-unlock.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>mutex</para></entry>
<entry role="parameter_description"><para>a <link linkend="GStaticMutex"><type>GStaticMutex</type></link>.</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="g-static-mutex-get-mutex" role="function" condition="deprecated:2.32: Just use a #GMutex">
<title>g_static_mutex_get_mutex&#160;()</title>
<indexterm zone="g-static-mutex-get-mutex" role="deprecated"><primary sortas="static_mutex_get_mutex">g_static_mutex_get_mutex</primary></indexterm>
<programlisting language="C"><link linkend="GMutex"><returnvalue>GMutex</returnvalue></link>&#160;*
g_static_mutex_get_mutex (<parameter><link linkend="GStaticMutex"><type>GStaticMutex</type></link> *mutex</parameter>);</programlisting>
<warning><para><literal>g_static_mutex_get_mutex</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>Just use a <link linkend="GMutex"><type>GMutex</type></link></para>
</warning>
<para>For some operations (like <link linkend="g-cond-wait"><function>g_cond_wait()</function></link>) you must have a <link linkend="GMutex"><type>GMutex</type></link>
instead of a <link linkend="GStaticMutex"><type>GStaticMutex</type></link>. This function will return the
corresponding <link linkend="GMutex"><type>GMutex</type></link> for <parameter>mutex</parameter>
.</para>
<refsect3 id="g-static-mutex-get-mutex.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>mutex</para></entry>
<entry role="parameter_description"><para>a <link linkend="GStaticMutex"><type>GStaticMutex</type></link>.</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-static-mutex-get-mutex.returns" role="returns">
<title>Returns</title>
<para> the <link linkend="GMutex"><type>GMutex</type></link> corresponding to <parameter>mutex</parameter>
.</para>
</refsect3></refsect2>
<refsect2 id="g-static-mutex-free" role="function" condition="deprecated:2.32: Use g_mutex_clear()">
<title>g_static_mutex_free&#160;()</title>
<indexterm zone="g-static-mutex-free" role="deprecated"><primary sortas="static_mutex_free">g_static_mutex_free</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_static_mutex_free (<parameter><link linkend="GStaticMutex"><type>GStaticMutex</type></link> *mutex</parameter>);</programlisting>
<warning><para><literal>g_static_mutex_free</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>Use <link linkend="g-mutex-clear"><function>g_mutex_clear()</function></link></para>
</warning>
<para>Releases all resources allocated to <parameter>mutex</parameter>
.</para>
<para>You don't have to call this functions for a <link linkend="GStaticMutex"><type>GStaticMutex</type></link> with an
unbounded lifetime, i.e. objects declared 'static', but if you have
a <link linkend="GStaticMutex"><type>GStaticMutex</type></link> as a member of a structure and the structure is
freed, you should also free the <link linkend="GStaticMutex"><type>GStaticMutex</type></link>.</para>
<para>Calling <link linkend="g-static-mutex-free"><function>g_static_mutex_free()</function></link> on a locked mutex may result in
undefined behaviour.</para>
<refsect3 id="g-static-mutex-free.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>mutex</para></entry>
<entry role="parameter_description"><para>a <link linkend="GStaticMutex"><type>GStaticMutex</type></link> to be freed.</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>

</refsect1>
<refsect1 id="glib-Deprecated-Thread-APIs.other_details" role="details">
<title role="details.title">Types and Values</title>
<refsect2 id="G-THREADS-IMPL-POSIX:CAPS" role="macro" condition="deprecated">
<title>G_THREADS_IMPL_POSIX</title>
<indexterm zone="G-THREADS-IMPL-POSIX:CAPS" role="deprecated"><primary sortas="THREADS_IMPL_POSIX">G_THREADS_IMPL_POSIX</primary></indexterm>
<programlisting language="C">#define G_THREADS_IMPL_POSIX
</programlisting>
<warning><para><literal>G_THREADS_IMPL_POSIX</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>POSIX threads are in use on all non-Windows systems.
                Use G_OS_WIN32 to detect Windows.</para>
</warning>
<para>This macro is defined if POSIX style threads are used.</para>
</refsect2>
<refsect2 id="G-THREADS-IMPL-WIN32:CAPS" role="macro" condition="deprecated:2.32:Use G_OS_WIN32 to detect Windows.">
<title>G_THREADS_IMPL_WIN32</title>
<indexterm zone="G-THREADS-IMPL-WIN32:CAPS" role="deprecated"><primary sortas="THREADS_IMPL_WIN32">G_THREADS_IMPL_WIN32</primary></indexterm>
<programlisting language="C">#define G_THREADS_IMPL_NONE
</programlisting>
<warning><para><literal>G_THREADS_IMPL_WIN32</literal> has been deprecated since version 2.32 and should not be used in newly-written code.</para> <para>Use G_OS_WIN32 to detect Windows.</para>
</warning>
<para>This macro is defined if Windows style threads are used.</para>
</refsect2>
<refsect2 id="GStaticMutex" role="struct">
<title>GStaticMutex</title>
<indexterm zone="GStaticMutex"><primary sortas="StaticMutex">GStaticMutex</primary></indexterm>
<programlisting language="C">typedef struct _GStaticMutex GStaticMutex;</programlisting>
<para>A <link linkend="GStaticMutex"><type>GStaticMutex</type></link> works like a <link linkend="GMutex"><type>GMutex</type></link>.</para>
<para>Prior to GLib 2.32, GStaticMutex had the significant advantage
that it doesn't need to be created at run-time, but can be defined
at compile-time. Since 2.32, <link linkend="GMutex"><type>GMutex</type></link> can be statically allocated
as well, and GStaticMutex has been deprecated.</para>
<para>Here is a version of our <link linkend="give-me-next-number"><function>give_me_next_number()</function></link> example using
a GStaticMutex:</para>
<informalexample><programlisting role="example"><![CDATA[
  int
  give_me_next_number (void)
  {
    static int current_number = 0;
    int ret_val;
    static GStaticMutex mutex = G_STATIC_MUTEX_INIT;

    g_static_mutex_lock (&mutex);
    ret_val = current_number = calc_next_number (current_number);
    g_static_mutex_unlock (&mutex);

    return ret_val;
  }
]]></programlisting></informalexample>
<para></para>
<para>Sometimes you would like to dynamically create a mutex. If you don't
want to require prior calling to <link linkend="g-thread-init"><function>g_thread_init()</function></link>, because your code
should also be usable in non-threaded programs, you are not able to
use <link linkend="g-mutex-new"><function>g_mutex_new()</function></link> and thus <link linkend="GMutex"><type>GMutex</type></link>, as that requires a prior call to
<link linkend="g-thread-init"><function>g_thread_init()</function></link>. In theses cases you can also use a <link linkend="GStaticMutex"><type>GStaticMutex</type></link>.
It must be initialized with <link linkend="g-static-mutex-init"><function>g_static_mutex_init()</function></link> before using it
and freed with with <link linkend="g-static-mutex-free"><function>g_static_mutex_free()</function></link> when not needed anymore to
free up any allocated resources.</para>
<para>Even though <link linkend="GStaticMutex"><type>GStaticMutex</type></link> is not opaque, it should only be used with
the following functions, as it is defined differently on different
platforms.</para>
<para>All of the g_static_mutex_* functions apart from
<link linkend="g-static-mutex-get-mutex"><function>g_static_mutex_get_mutex()</function></link> can also be used even if <link linkend="g-thread-init"><function>g_thread_init()</function></link>
has not yet been called. Then they do nothing, apart from
<link linkend="g-static-mutex-trylock"><function>g_static_mutex_trylock()</function></link> which does nothing but returning <link linkend="TRUE:CAPS"><literal>TRUE</literal></link>.</para>
<para>All of the g_static_mutex_* functions are actually macros. Apart from
taking their addresses, you can however use them as if they were
functions.</para>
</refsect2>
<refsect2 id="G-STATIC-MUTEX-INIT:CAPS" role="macro">
<title>G_STATIC_MUTEX_INIT</title>
<indexterm zone="G-STATIC-MUTEX-INIT:CAPS"><primary sortas="STATIC_MUTEX_INIT">G_STATIC_MUTEX_INIT</primary></indexterm>
<programlisting language="C">#define G_STATIC_MUTEX_INIT
</programlisting>
<para>A <link linkend="GStaticMutex"><type>GStaticMutex</type></link> 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
<link linkend="g-static-mutex-init"><function>g_static_mutex_init()</function></link>.</para>
<informalexample><programlisting role="example"><![CDATA[
GStaticMutex my_mutex = G_STATIC_MUTEX_INIT;
]]></programlisting></informalexample>
<para></para>
</refsect2>
<refsect2 id="G-STATIC-PRIVATE-INIT:CAPS" role="macro">
<title>G_STATIC_PRIVATE_INIT</title>
<indexterm zone="G-STATIC-PRIVATE-INIT:CAPS"><primary sortas="STATIC_PRIVATE_INIT">G_STATIC_PRIVATE_INIT</primary></indexterm>
<programlisting language="C">#define G_STATIC_PRIVATE_INIT

</programlisting>
<para>Every <link linkend="GStaticPrivate"><type>GStaticPrivate</type></link> must be initialized with this macro, before it
can be used.</para>
<informalexample><programlisting role="example"><![CDATA[
  GStaticPrivate my_private = G_STATIC_PRIVATE_INIT;
]]></programlisting></informalexample>
<para></para>
</refsect2>

</refsect1>
<refsect1 id="glib-Deprecated-Thread-APIs.see-also">
<title>See Also</title>
<para><link linkend="GThread"><type>GThread</type></link></para>

</refsect1>

</refentry>
