~ubuntu-branches/ubuntu/precise/glib2.0/precise-updates

« back to all changes in this revision

Viewing changes to docs/reference/glib/html/glib-Threads.html

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2012-01-10 16:23:46 UTC
  • mfrom: (1.59.35)
  • Revision ID: package-import@ubuntu.com-20120110162346-5s54yf7s1va1zb6i
Tags: 2.31.8-0ubuntu1
* New upstream version, drop patch which is in the new version
* debian/libglib2.0-0.symbols: new version update

Show diffs side-by-side

added added

removed removed

Lines of Context:
228
228
threads. The two notable exceptions from this rule are <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>
229
229
and <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a>, which <span class="emphasis"><em>are</em></span> thread-safe and
230
230
need no further application-level locking to be accessed from
231
 
multiple threads. Most refcounting functions such as <a href="./../gobject/gobject/gobject-The-Base-Object-Type.html#g-object-ref"><code class="function">g_object_ref()</code></a>
 
231
multiple threads. Most refcounting functions such as <a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-ref"><code class="function">g_object_ref()</code></a>
232
232
are also thread-safe.
233
233
</p>
234
234
</div>
578
578
<p>
579
579
</p>
580
580
<div class="example">
581
 
<a name="id435675"></a><p class="title"><b>Example 2. A function which will not work in a threaded environment</b></p>
 
581
<a name="id530603"></a><p class="title"><b>Example 2. A function which will not work in a threaded environment</b></p>
582
582
<div class="example-contents">
583
583
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
584
584
    <tbody>
623
623
<p>
624
624
</p>
625
625
<div class="example">
626
 
<a name="id435711"></a><p class="title"><b>Example 3. Using GMutex to protected a shared variable</b></p>
 
626
<a name="id530640"></a><p class="title"><b>Example 3. Using GMutex to protected a shared variable</b></p>
627
627
<div class="example-contents">
628
628
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
629
629
    <tbody>
775
775
thread.
776
776
</p>
777
777
<p>
778
 
This function can be used even if <a class="link" href="glib-Deprecated-Thread-APIs.html#g-thread-init" title="g_thread_init ()"><code class="function">g_thread_init()</code></a> has not yet been
779
 
called, and, in that case, will do nothing.
780
 
</p>
781
 
<p>
782
778
</p>
783
779
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
784
780
<h3 class="title">Note</h3>
807
803
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>.
808
804
</p>
809
805
<p>
810
 
This function can be used even if <a class="link" href="glib-Deprecated-Thread-APIs.html#g-thread-init" title="g_thread_init ()"><code class="function">g_thread_init()</code></a> has not yet been
811
 
called, and, in that case, will immediately return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>.
812
 
</p>
813
 
<p>
814
806
</p>
815
807
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
816
808
<h3 class="title">Note</h3>
849
841
Calling <a class="link" href="glib-Threads.html#g-mutex-unlock" title="g_mutex_unlock ()"><code class="function">g_mutex_unlock()</code></a> on a mutex that is not locked by the
850
842
current thread leads to undefined behaviour.
851
843
</p>
852
 
<p>
853
 
This function can be used even if <a class="link" href="glib-Deprecated-Thread-APIs.html#g-thread-init" title="g_thread_init ()"><code class="function">g_thread_init()</code></a> has not yet been
854
 
called, and, in that case, will do nothing.
855
 
</p>
856
844
<div class="variablelist"><table border="0">
857
845
<col align="left" valign="top">
858
846
<tbody><tr>
881
869
<p>
882
870
</p>
883
871
<div class="example">
884
 
<a name="id436618"></a><p class="title"><b>Example 4. Using the <code class="literal">G_LOCK_*</code> convenience macros</b></p>
 
872
<a name="id531493"></a><p class="title"><b>Example 4. Using the <code class="literal">G_LOCK_*</code> convenience macros</b></p>
885
873
<div class="example-contents">
886
874
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
887
875
    <tbody>
1231
1219
<p>
1232
1220
</p>
1233
1221
<div class="example">
1234
 
<a name="id437860"></a><p class="title"><b>Example 5. An array with access functions</b></p>
 
1222
<a name="id532735"></a><p class="title"><b>Example 5. An array with access functions</b></p>
1235
1223
<div class="example-contents">
1236
1224
<pre class="programlisting">
1237
1225
  GRWLock lock;
1539
1527
<p>
1540
1528
</p>
1541
1529
<div class="example">
1542
 
<a name="id439013"></a><p class="title"><b>Example 6. 
 
1530
<a name="id533888"></a><p class="title"><b>Example 6. 
1543
1531
  Using GCond to block a thread until a condition is satisfied
1544
1532
 </b></p>
1545
1533
<div class="example-contents">
1910
1898
It is good practice to hold the same lock as the waiting thread
1911
1899
while calling this function, though not required.
1912
1900
</p>
1913
 
<p>
1914
 
This function can be used even if <a class="link" href="glib-Deprecated-Thread-APIs.html#g-thread-init" title="g_thread_init ()"><code class="function">g_thread_init()</code></a> has not yet been
1915
 
called, and, in that case, will do nothing.
1916
 
</p>
1917
1901
<div class="variablelist"><table border="0">
1918
1902
<col align="left" valign="top">
1919
1903
<tbody><tr>
1933
1917
It is good practice to lock the same mutex as the waiting threads
1934
1918
while calling this function, though not required.
1935
1919
</p>
1936
 
<p>
1937
 
This function can be used even if <a class="link" href="glib-Deprecated-Thread-APIs.html#g-thread-init" title="g_thread_init ()"><code class="function">g_thread_init()</code></a> has not yet been
1938
 
called, and, in that case, will do nothing.
1939
 
</p>
1940
1920
<div class="variablelist"><table border="0">
1941
1921
<col align="left" valign="top">
1942
1922
<tbody><tr>