OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [doc/] [html/] [manual/] [bk01pt12ch41s03.html] - Blame information for rev 424

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Use</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><meta name="keywords" content="&#10;      ISO C++&#10;    , &#10;      library&#10;    " /><meta name="keywords" content="&#10;      ISO C++&#10;    , &#10;      library&#10;    " /><link rel="home" href="../spine.html" title="The GNU C++ Library Documentation" /><link rel="up" href="ext_concurrency.html" title="Chapter 41. Concurrency" /><link rel="prev" href="bk01pt12ch41s02.html" title="Implementation" /><link rel="next" href="appendix_contributing.html" title="Appendix A.  Contributing" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Use</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="bk01pt12ch41s02.html">Prev</a> </td><th width="60%" align="center">Chapter 41. Concurrency</th><td width="20%" align="right"> <a accesskey="n" href="appendix_contributing.html">Next</a></td></tr></table><hr /></div><div class="sect1" title="Use"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="manual.ext.concurrency.use"></a>Use</h2></div></div></div><p>Typical usage of the last two constructs is demonstrated as follows:
4
</p><pre class="programlisting">
5
#include &lt;ext/concurrence.h&gt;
6
 
7
namespace
8
{
9
  __gnu_cxx::__mutex safe_base_mutex;
10
} // anonymous namespace
11
 
12
namespace other
13
{
14
  void
15
  foo()
16
  {
17
    __gnu_cxx::__scoped_lock sentry(safe_base_mutex);
18
    for (int i = 0; i &lt; max;  ++i)
19
      {
20
        _Safe_iterator_base* __old = __iter;
21
        __iter = __iter-&lt;_M_next;
22
        __old-&lt;_M_detach_single();
23
      }
24
}
25
</pre><p>In this sample code, an anonymous namespace is used to keep
26
the <code class="code">__mutex</code> private to the compilation unit,
27
and <code class="code">__scoped_lock</code> is used to guard access to the critical
28
section within the for loop, locking the mutex on creation and freeing
29
the mutex as control moves out of this block.
30
</p><p>Several exception classes are used to keep track of
31
concurrence-related errors. These classes
32
are: <code class="code">__concurrence_lock_error</code>, <code class="code">__concurrence_unlock_error</code>, <code class="code">__concurrence_wait_error</code>,
33
and <code class="code">__concurrence_broadcast_error</code>.
34
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="bk01pt12ch41s02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ext_concurrency.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="appendix_contributing.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Implementation </td><td width="20%" align="center"><a accesskey="h" href="../spine.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix A. 
35
  Contributing
36
 
37
</td></tr></table></div></body></html>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.