diff options
Diffstat (limited to 'libstdc++-v3/doc/html/manual/bk01pt12ch40s03.html')
-rw-r--r-- | libstdc++-v3/doc/html/manual/bk01pt12ch40s03.html | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libstdc++-v3/doc/html/manual/bk01pt12ch40s03.html b/libstdc++-v3/doc/html/manual/bk01pt12ch40s03.html new file mode 100644 index 00000000000..b67d0f7fbf5 --- /dev/null +++ b/libstdc++-v3/doc/html/manual/bk01pt12ch40s03.html @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<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.73.2" /><meta name="keywords" content=" ISO C++ , library " /><meta name="keywords" content=" ISO C++ , library " /><link rel="start" href="../spine.html" title="The GNU C++ Library Documentation" /><link rel="up" href="concurrency.html" title="Chapter 40. Concurrency" /><link rel="prev" href="bk01pt12ch40s02.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="bk01pt12ch40s02.html">Prev</a> </td><th width="60%" align="center">Chapter 40. Concurrency</th><td width="20%" align="right"> <a accesskey="n" href="appendix_contributing.html">Next</a></td></tr></table><hr /></div><div class="sect1" lang="en" xml:lang="en"><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: +</p><pre class="programlisting"> +#include <ext/concurrence.h> + +namespace +{ + __gnu_cxx::__mutex safe_base_mutex; +} // anonymous namespace + +namespace other +{ + void + foo() + { + __gnu_cxx::__scoped_lock sentry(safe_base_mutex); + for (int i = 0; i < max; ++i) + { + _Safe_iterator_base* __old = __iter; + __iter = __iter-<_M_next; + __old-<_M_detach_single(); + } +} +</pre><p>In this sample code, an anonymous namespace is used to keep +the <code class="code">__mutex</code> private to the compilation unit, +and <code class="code">__scoped_lock</code> is used to guard access to the critical +section within the for loop, locking the mutex on creation and freeing +the mutex as control moves out of this block. +</p><p>Several exception classes are used to keep track of +concurrence-related errors. These classes +are: <code class="code">__concurrence_lock_error</code>, <code class="code">__concurrence_unlock_error</code>, <code class="code">__concurrence_wait_error</code>, +and <code class="code">__concurrence_broadcast_error</code>. +</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="bk01pt12ch40s02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="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. Contributing</td></tr></table></div></body></html> |