diff options
author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-02-09 01:45:25 +0000 |
---|---|---|
committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-02-09 01:45:25 +0000 |
commit | 073f5bbd032d5a38d4b6422be93455ffd076ef58 (patch) | |
tree | 941724e5e92d146f214e6c99047018d99612d4e3 /libstdc++-v3/doc/html/manual/memory.html | |
parent | ee5533bac71afd276a65aafdd15487c428f8d54b (diff) | |
download | ppe42-gcc-073f5bbd032d5a38d4b6422be93455ffd076ef58.tar.gz ppe42-gcc-073f5bbd032d5a38d4b6422be93455ffd076ef58.zip |
2011-02-08 Benjamin Kosnik <bkoz@redhat.com>
* doc/html/*: Regenerate.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169960 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/doc/html/manual/memory.html')
-rw-r--r-- | libstdc++-v3/doc/html/manual/memory.html | 166 |
1 files changed, 71 insertions, 95 deletions
diff --git a/libstdc++-v3/doc/html/manual/memory.html b/libstdc++-v3/doc/html/manual/memory.html index 92e8b7f471e..a86bc29bcfe 100644 --- a/libstdc++-v3/doc/html/manual/memory.html +++ b/libstdc++-v3/doc/html/manual/memory.html @@ -1,15 +1,15 @@ <?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>Memory</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><meta name="keywords" content=" ISO C++ , library " /><link rel="home" href="../spine.html" title="The GNU C++ Library Documentation" /><link rel="up" href="utilities.html" title="Chapter 6. Utilities" /><link rel="prev" href="pairs.html" title="Pairs" /><link rel="next" href="traits.html" title="Traits" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Memory</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="pairs.html">Prev</a> </td><th width="60%" align="center">Chapter 6. +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Memory</title><meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1"/><meta name="keywords" content=" ISO C++ , library "/><link rel="home" href="../spine.html" title="The GNU C++ Library"/><link rel="up" href="utilities.html" title="Chapter 6. Utilities"/><link rel="prev" href="pairs.html" title="Pairs"/><link rel="next" href="traits.html" title="Traits"/></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Memory</th></tr><tr><td align="left"><a accesskey="p" href="pairs.html">Prev</a> </td><th width="60%" align="center">Chapter 6. Utilities -</th><td width="20%" align="right"> <a accesskey="n" href="traits.html">Next</a></td></tr></table><hr /></div><div class="section" title="Memory"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="std.util.memory"></a>Memory</h2></div></div></div><p> +</th><td align="right"> <a accesskey="n" href="traits.html">Next</a></td></tr></table><hr/></div><div class="section" title="Memory"><div class="titlepage"><div><div><h2 class="title"><a id="std.util.memory"/>Memory</h2></div></div></div><p> Memory contains three general areas. First, function and operator calls via <code class="function">new</code> and <code class="function">delete</code> operator or member function calls. Second, allocation via <code class="classname">allocator</code>. And finally, smart pointer and intelligent pointer abstractions. - </p><div class="section" title="Allocators"><div class="titlepage"><div><div><h3 class="title"><a id="std.util.memory.allocator"></a>Allocators</h3></div></div></div><p> + </p><div class="section" title="Allocators"><div class="titlepage"><div><div><h3 class="title"><a id="std.util.memory.allocator"/>Allocators</h3></div></div></div><p> Memory management for Standard Library entities is encapsulated in a class template called <code class="classname">allocator</code>. The <code class="classname">allocator</code> abstraction is used throughout the @@ -17,9 +17,9 @@ algorithms, and parts of iostreams. This class, and base classes of it, are the superset of available free store (<span class="quote">“<span class="quote">heap</span>”</span>) management classes. -</p><div class="section" title="Requirements"><div class="titlepage"><div><div><h4 class="title"><a id="allocator.req"></a>Requirements</h4></div></div></div><p> +</p><div class="section" title="Requirements"><div class="titlepage"><div><div><h4 class="title"><a id="allocator.req"/>Requirements</h4></div></div></div><p> The C++ standard only gives a few directives in this area: - </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p> + </p><div class="itemizedlist"><ul class="itemizedlist"><li class="listitem"><p> When you add elements to a container, and the container must allocate more memory to hold them, the container makes the request via its <span class="type">Allocator</span> template @@ -54,11 +54,11 @@ </p></li></ul></div><p> Complete details can be found in the C++ standard, look in <code class="constant">[20.4 Memory]</code>. - </p></div><div class="section" title="Design Issues"><div class="titlepage"><div><div><h4 class="title"><a id="allocator.design_issues"></a>Design Issues</h4></div></div></div><p> + </p></div><div class="section" title="Design Issues"><div class="titlepage"><div><div><h4 class="title"><a id="allocator.design_issues"/>Design Issues</h4></div></div></div><p> The easiest way of fulfilling the requirements is to call <code class="function">operator new</code> each time a container needs memory, and to call <code class="function">operator delete</code> each time - the container releases memory. This method may be <a class="ulink" href="http://gcc.gnu.org/ml/libstdc++/2001-05/msg00105.html" target="_top">slower</a> + the container releases memory. This method may be <a class="link" href="http://gcc.gnu.org/ml/libstdc++/2001-05/msg00105.html">slower</a> than caching the allocations and re-using previously-allocated memory, but has the advantage of working correctly across a wide variety of hardware and operating systems, including large @@ -93,7 +93,7 @@ or loading and unloading shared objects in memory. As such, using caching allocators on systems that do not support <code class="function">abi::__cxa_atexit</code> is not recommended. - </p></div><div class="section" title="Implementation"><div class="titlepage"><div><div><h4 class="title"><a id="allocator.impl"></a>Implementation</h4></div></div></div><div class="section" title="Interface Design"><div class="titlepage"><div><div><h5 class="title"><a id="id377805"></a>Interface Design</h5></div></div></div><p> + </p></div><div class="section" title="Implementation"><div class="titlepage"><div><div><h4 class="title"><a id="allocator.impl"/>Implementation</h4></div></div></div><div class="section" title="Interface Design"><div class="titlepage"><div><div><h5 class="title"><a id="id476111"/>Interface Design</h5></div></div></div><p> The only allocator interface that is supported is the standard C++ interface. As such, all STL containers have been adjusted, and all external allocators have @@ -106,7 +106,7 @@ </p><p> The base class that <code class="classname">allocator</code> is derived from may not be user-configurable. -</p></div><div class="section" title="Selecting Default Allocation Policy"><div class="titlepage"><div><div><h5 class="title"><a id="id406368"></a>Selecting Default Allocation Policy</h5></div></div></div><p> +</p></div><div class="section" title="Selecting Default Allocation Policy"><div class="titlepage"><div><div><h5 class="title"><a id="id476140"/>Selecting Default Allocation Policy</h5></div></div></div><p> It's difficult to pick an allocation strategy that will provide maximum utility, without excessively penalizing some behavior. In fact, it's difficult just deciding which typical actions to measure @@ -114,14 +114,14 @@ </p><p> Three synthetic benchmarks have been created that provide data that is used to compare different C++ allocators. These tests are: - </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p> + </p><div class="orderedlist"><ol class="orderedlist"><li class="listitem"><p> Insertion. </p><p> Over multiple iterations, various STL container objects have elements inserted to some maximum amount. A variety of allocators are tested. - Test source for <a class="ulink" href="http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/testsuite/performance/23_containers/insert/sequence.cc?view=markup" target="_top">sequence</a> - and <a class="ulink" href="http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/testsuite/performance/23_containers/insert/associative.cc?view=markup" target="_top">associative</a> + Test source for <a class="link" href="http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/testsuite/performance/23_containers/insert/sequence.cc?view=markup">sequence</a> + and <a class="link" href="http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/testsuite/performance/23_containers/insert/associative.cc?view=markup">associative</a> containers. </p></li><li class="listitem"><p> Insertion and erasure in a multi-threaded environment. @@ -130,20 +130,20 @@ on a per-thread basis, as well as measuring thread contention for memory resources. Test source - <a class="ulink" href="http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/testsuite/performance/23_containers/insert_erase/associative.cc?view=markup" target="_top">here</a>. + <a class="link" href="http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/testsuite/performance/23_containers/insert_erase/associative.cc?view=markup">here</a>. </p></li><li class="listitem"><p> A threaded producer/consumer model. </p><p> Test source for - <a class="ulink" href="http://gcc.gnu.org/viewcvs/trunk/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/sequence.cc?view=markup" target="_top">sequence</a> + <a class="link" href="http://gcc.gnu.org/viewcvs/trunk/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/sequence.cc?view=markup">sequence</a> and - <a class="ulink" href="http://gcc.gnu.org/viewcvs/trunk/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/associative.cc?view=markup" target="_top">associative</a> + <a class="link" href="http://gcc.gnu.org/viewcvs/trunk/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/associative.cc?view=markup">associative</a> containers. </p></li></ol></div><p> The current default choice for <code class="classname">allocator</code> is <code class="classname">__gnu_cxx::new_allocator</code>. - </p></div><div class="section" title="Disabling Memory Caching"><div class="titlepage"><div><div><h5 class="title"><a id="id394979"></a>Disabling Memory Caching</h5></div></div></div><p> + </p></div><div class="section" title="Disabling Memory Caching"><div class="titlepage"><div><div><h5 class="title"><a id="id476251"/>Disabling Memory Caching</h5></div></div></div><p> In use, <code class="classname">allocator</code> may allocate and deallocate using implementation-specified strategies and heuristics. Because of this, every call to an allocator object's @@ -179,7 +179,7 @@ environment, it likely means that you linked against objects built against the older library (objects which might still using the cached allocations...). - </p></div></div><div class="section" title="Using a Specific Allocator"><div class="titlepage"><div><div><h4 class="title"><a id="allocator.using"></a>Using a Specific Allocator</h4></div></div></div><p> + </p></div></div><div class="section" title="Using a Specific Allocator"><div class="titlepage"><div><div><h4 class="title"><a id="allocator.using"/>Using a Specific Allocator</h4></div></div></div><p> You can specify different memory management schemes on a per-container basis, by overriding the default <span class="type">Allocator</span> template parameter. For example, an easy @@ -190,7 +190,7 @@ Likewise, a debugging form of whichever allocator is currently in use: </p><pre class="programlisting"> std::deque <int, __gnu_cxx::debug_allocator<std::allocator<int> > > debug_deque; - </pre></div><div class="section" title="Custom Allocators"><div class="titlepage"><div><div><h4 class="title"><a id="allocator.custom"></a>Custom Allocators</h4></div></div></div><p> + </pre></div><div class="section" title="Custom Allocators"><div class="titlepage"><div><div><h4 class="title"><a id="allocator.custom"/>Custom Allocators</h4></div></div></div><p> Writing a portable C++ allocator would dictate that the interface would look much like the one specified for <code class="classname">allocator</code>. Additional member functions, but @@ -199,7 +199,7 @@ Probably the best place to start would be to copy one of the extension allocators: say a simple one like <code class="classname">new_allocator</code>. - </p></div><div class="section" title="Extension Allocators"><div class="titlepage"><div><div><h4 class="title"><a id="allocator.ext"></a>Extension Allocators</h4></div></div></div><p> + </p></div><div class="section" title="Extension Allocators"><div class="titlepage"><div><div><h4 class="title"><a id="allocator.ext"/>Extension Allocators</h4></div></div></div><p> Several other allocators are provided as part of this implementation. The location of the extension allocators and their names have changed, but in all cases, functionality is @@ -209,7 +209,7 @@ chart to track the changes. </p><p> More details on each of these extension allocators follows. - </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p> + </p><div class="orderedlist"><ol class="orderedlist"><li class="listitem"><p> <code class="classname">new_allocator</code> </p><p> Simply wraps <code class="function">::operator new</code> @@ -308,41 +308,29 @@ A high-performance allocator that uses a bit-map to keep track of the used and unused memory locations. It has its own documentation, found <a class="link" href="bitmap_allocator.html" title="bitmap_allocator">here</a>. - </p></li></ol></div></div><div class="bibliography" title="Bibliography"><div class="titlepage"><div><div><h4 class="title"><a id="allocator.biblio"></a>Bibliography</h4></div></div></div><div class="biblioentry" title="ISO/IEC 14882:1998 Programming languages - C++"><a id="id399256"></a><p><span class="title"><i> + </p></li></ol></div></div><div class="bibliography" title="Bibliography"><div class="titlepage"><div><div><h4 class="title"><a id="allocator.biblio"/>Bibliography</h4></div></div></div><div class="biblioentry"><a id="id476702"/><p><span class="citetitle"><em class="citetitle"> ISO/IEC 14882:1998 Programming languages - C++ - </i>. </span> + </em>. </span> isoc++_1998 - <span class="pagenums">20.4 Memory. </span></p></div><div class="biblioentry"><a id="id399271"></a><p><span class="biblioid"> - <a class="ulink" href="http://www.drdobbs.com/cpp/184403759" target="_top"> - <em class="citetitle"> - The Standard Librarian: What Are Allocators Good For? - </em> - </a> - . </span><span class="author"><span class="firstname">Matt</span> <span class="surname">Austern</span>. </span><span class="publisher"><span class="publishername"> + <span class="pagenums">20.4 Memory. </span></p></div><div class="biblioentry"><a id="id476717"/><p><span class="biblioid"> + . </span><span class="citetitle"><em class="citetitle"> + The Standard Librarian: What Are Allocators Good For? + </em>. </span><span class="author"><span class="firstname">Matt</span> <span class="surname">Austern</span>. </span><span class="publisher"><span class="publishername"> C/C++ Users Journal - . </span></span></p></div><div class="biblioentry"><a id="id405510"></a><p><span class="biblioid"> - <a class="ulink" href="http://www.cs.umass.edu/~emery/hoard/" target="_top"> - <em class="citetitle"> - The Hoard Memory Allocator - </em> - </a> - . </span><span class="author"><span class="firstname">Emery</span> <span class="surname">Berger</span>. </span></p></div><div class="biblioentry"><a id="id451188"></a><p><span class="biblioid"> - <a class="ulink" href="http://www.cs.umass.edu/~emery/pubs/berger-oopsla2002.pdf" target="_top"> - <em class="citetitle"> - Reconsidering Custom Memory Allocation - </em> - </a> - . </span><span class="author"><span class="firstname">Emery</span> <span class="surname">Berger</span>. </span><span class="author"><span class="firstname">Ben</span> <span class="surname">Zorn</span>. </span><span class="author"><span class="firstname">Kathryn</span> <span class="surname">McKinley</span>. </span><span class="copyright">Copyright © 2002 OOPSLA. </span></p></div><div class="biblioentry"><a id="id387032"></a><p><span class="biblioid"> - <a class="ulink" href="http://www.angelikalanger.com/Articles/C++Report/Allocators/Allocators.html" target="_top"> - <em class="citetitle"> - Allocator Types - </em> - </a> - . </span><span class="author"><span class="firstname">Klaus</span> <span class="surname">Kreft</span>. </span><span class="author"><span class="firstname">Angelika</span> <span class="surname">Langer</span>. </span><span class="publisher"><span class="publishername"> + . </span></span></p></div><div class="biblioentry"><a id="id476750"/><p><span class="biblioid"> + . </span><span class="citetitle"><em class="citetitle"> + The Hoard Memory Allocator + </em>. </span><span class="author"><span class="firstname">Emery</span> <span class="surname">Berger</span>. </span></p></div><div class="biblioentry"><a id="id476776"/><p><span class="biblioid"> + . </span><span class="citetitle"><em class="citetitle"> + Reconsidering Custom Memory Allocation + </em>. </span><span class="author"><span class="firstname">Emery</span> <span class="surname">Berger</span>. </span><span class="author"><span class="firstname">Ben</span> <span class="surname">Zorn</span>. </span><span class="author"><span class="firstname">Kathryn</span> <span class="surname">McKinley</span>. </span><span class="copyright">Copyright © 2002 OOPSLA. </span></p></div><div class="biblioentry"><a id="id476830"/><p><span class="biblioid"> + . </span><span class="citetitle"><em class="citetitle"> + Allocator Types + </em>. </span><span class="author"><span class="firstname">Klaus</span> <span class="surname">Kreft</span>. </span><span class="author"><span class="firstname">Angelika</span> <span class="surname">Langer</span>. </span><span class="publisher"><span class="publishername"> C/C++ Users Journal - . </span></span></p></div><div class="biblioentry" title="The C++ Programming Language"><a id="id392077"></a><p><span class="title"><i>The C++ Programming Language</i>. </span><span class="author"><span class="firstname">Bjarne</span> <span class="surname">Stroustrup</span>. </span><span class="copyright">Copyright © 2000 . </span><span class="pagenums">19.4 Allocators. </span><span class="publisher"><span class="publishername"> + . </span></span></p></div><div class="biblioentry"><a id="id476871"/><p><span class="citetitle"><em class="citetitle">The C++ Programming Language</em>. </span><span class="author"><span class="firstname">Bjarne</span> <span class="surname">Stroustrup</span>. </span><span class="copyright">Copyright © 2000 . </span><span class="pagenums">19.4 Allocators. </span><span class="publisher"><span class="publishername"> Addison Wesley - . </span></span></p></div><div class="biblioentry" title="Yalloc: A Recycling C++ Allocator"><a id="id443714"></a><p><span class="title"><i>Yalloc: A Recycling C++ Allocator</i>. </span><span class="author"><span class="firstname">Felix</span> <span class="surname">Yen</span>. </span></p></div></div></div><div class="section" title="auto_ptr"><div class="titlepage"><div><div><h3 class="title"><a id="std.util.memory.auto_ptr"></a>auto_ptr</h3></div></div></div><div class="section" title="Limitations"><div class="titlepage"><div><div><h4 class="title"><a id="auto_ptr.limitations"></a>Limitations</h4></div></div></div><p>Explaining all of the fun and delicious things that can + . </span></span></p></div><div class="biblioentry"><a id="id476908"/><p><span class="citetitle"><em class="citetitle">Yalloc: A Recycling C++ Allocator</em>. </span><span class="author"><span class="firstname">Felix</span> <span class="surname">Yen</span>. </span></p></div></div></div><div class="section" title="auto_ptr"><div class="titlepage"><div><div><h3 class="title"><a id="std.util.memory.auto_ptr"/>auto_ptr</h3></div></div></div><div class="section" title="Limitations"><div class="titlepage"><div><div><h4 class="title"><a id="auto_ptr.limitations"/>Limitations</h4></div></div></div><p>Explaining all of the fun and delicious things that can happen with misuse of the <code class="classname">auto_ptr</code> class template (called <acronym class="acronym">AP</acronym> here) would take some time. Suffice it to say that the use of <acronym class="acronym">AP</acronym> @@ -393,7 +381,7 @@ to die. AP is trivial to write, however, so you could write your own <code class="code">auto_array_ptr</code> for that situation (in fact, this has been done many times; check the mailing lists, Usenet, Boost, etc). - </p></div><div class="section" title="Use in Containers"><div class="titlepage"><div><div><h4 class="title"><a id="auto_ptr.using"></a>Use in Containers</h4></div></div></div><p> + </p></div><div class="section" title="Use in Containers"><div class="titlepage"><div><div><h4 class="title"><a id="auto_ptr.using"/>Use in Containers</h4></div></div></div><p> </p><p>All of the <a class="link" href="containers.html" title="Chapter 9. Containers">containers</a> described in the standard library require their contained types to have, among other things, a copy constructor like this: @@ -429,10 +417,10 @@ } </pre><p> Should you try this with the checks enabled, you will see an error. - </p></div></div><div class="section" title="shared_ptr"><div class="titlepage"><div><div><h3 class="title"><a id="std.util.memory.shared_ptr"></a>shared_ptr</h3></div></div></div><p> + </p></div></div><div class="section" title="shared_ptr"><div class="titlepage"><div><div><h3 class="title"><a id="std.util.memory.shared_ptr"/>shared_ptr</h3></div></div></div><p> The shared_ptr class template stores a pointer, usually obtained via new, and implements shared ownership semantics. -</p><div class="section" title="Requirements"><div class="titlepage"><div><div><h4 class="title"><a id="shared_ptr.req"></a>Requirements</h4></div></div></div><p> +</p><div class="section" title="Requirements"><div class="titlepage"><div><div><h4 class="title"><a id="shared_ptr.req"/>Requirements</h4></div></div></div><p> </p><p> The standard deliberately doesn't require a reference-counted implementation, allowing other techniques such as a @@ -444,7 +432,7 @@ and implements shared ownership semantics. shared_ptr in libstdc++ is derived from Boost's, so the same rules apply. </p><p> - </p></div><div class="section" title="Design Issues"><div class="titlepage"><div><div><h4 class="title"><a id="shared_ptr.design_issues"></a>Design Issues</h4></div></div></div><p> + </p></div><div class="section" title="Design Issues"><div class="titlepage"><div><div><h4 class="title"><a id="shared_ptr.design_issues"/>Design Issues</h4></div></div></div><p> The <code class="classname">shared_ptr</code> code is kindly donated to GCC by the Boost project and the original authors of the code. The basic design and algorithms are from Boost, the notes below describe details specific to @@ -458,7 +446,7 @@ drops to zero. Derived classes override those functions to destroy resources in a context where the correct dynamic type is known. This is an application of the technique known as type erasure. - </p></div><div class="section" title="Implementation"><div class="titlepage"><div><div><h4 class="title"><a id="shared_ptr.impl"></a>Implementation</h4></div></div></div><div class="section" title="Class Hierarchy"><div class="titlepage"><div><div><h5 class="title"><a id="id389991"></a>Class Hierarchy</h5></div></div></div><p> + </p></div><div class="section" title="Implementation"><div class="titlepage"><div><div><h4 class="title"><a id="shared_ptr.impl"/>Implementation</h4></div></div></div><div class="section" title="Class Hierarchy"><div class="titlepage"><div><div><h5 class="title"><a id="id477269"/>Class Hierarchy</h5></div></div></div><p> A <code class="classname">shared_ptr<T></code> contains a pointer of type <span class="type">T*</span> and an object of type <code class="classname">__shared_count</code>. The shared_count contains a @@ -500,14 +488,14 @@ be forwarded to <span class="type">Tp</span>'s constructor. Unlike the other <code class="classname">_Sp_counted_*</code> classes, this one is parameterized on the type of object, not the type of pointer; this is purely a convenience that simplifies the implementation slightly. - </p></dd></dl></div></div><div class="section" title="Thread Safety"><div class="titlepage"><div><div><h5 class="title"><a id="id388735"></a>Thread Safety</h5></div></div></div><p> + </p></dd></dl></div></div><div class="section" title="Thread Safety"><div class="titlepage"><div><div><h5 class="title"><a id="id477447"/>Thread Safety</h5></div></div></div><p> C++0x-only features are: rvalue-ref/move support, allocator support, aliasing constructor, make_shared & allocate_shared. Additionally, the constructors taking <code class="classname">auto_ptr</code> parameters are deprecated in C++0x mode. </p><p> The -<a class="ulink" href="http://boost.org/libs/smart_ptr/shared_ptr.htm#ThreadSafety" target="_top">Thread +<a class="link" href="http://boost.org/libs/smart_ptr/shared_ptr.htm#ThreadSafety">Thread Safety</a> section of the Boost shared_ptr documentation says "shared_ptr objects offer the same level of thread safety as built-in types." The implementation must ensure that concurrent updates to separate shared_ptr @@ -550,7 +538,7 @@ compiler, standard library, platform etc. For the version of shared_ptr in libstdc++ the compiler and library are fixed, which makes things much simpler: we have an atomic CAS or we don't, see Lock Policy below for details. -</p></div><div class="section" title="Selecting Lock Policy"><div class="titlepage"><div><div><h5 class="title"><a id="id480578"></a>Selecting Lock Policy</h5></div></div></div><p> +</p></div><div class="section" title="Selecting Lock Policy"><div class="titlepage"><div><div><h5 class="title"><a id="id477517"/>Selecting Lock Policy</h5></div></div></div><p> </p><p> There is a single <code class="classname">_Sp_counted_base</code> class, which is a template parameterized on the enum @@ -566,11 +554,11 @@ specialization will be used. This design is necessary because it would not be conforming for <code class="classname">shared_ptr</code> to have an extra template parameter, even if it had a default value. The available policies are: - </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p> + </p><div class="orderedlist"><ol class="orderedlist"><li class="listitem"><p> <span class="type">_S_Atomic</span> </p><p> Selected when GCC supports a builtin atomic compare-and-swap operation -on the target processor (see <a class="ulink" href="http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html" target="_top">Atomic +on the target processor (see <a class="link" href="http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html">Atomic Builtins</a>.) The reference counts are maintained using a lock-free algorithm and GCC's atomic builtins, which provide the required memory synchronisation. @@ -591,7 +579,7 @@ used when libstdc++ is built without <code class="literal">--enable-threads</cod <code class="filename">ext/atomicity.h</code>, which detect if the program is multi-threaded. If only one thread of execution exists in the program then less expensive non-atomic operations are used. - </p></div><div class="section" title="Dual C++0x and TR1 Implementation"><div class="titlepage"><div><div><h5 class="title"><a id="id399352"></a>Dual C++0x and TR1 Implementation</h5></div></div></div><p> + </p></div><div class="section" title="Dual C++0x and TR1 Implementation"><div class="titlepage"><div><div><h5 class="title"><a id="id477639"/>Dual C++0x and TR1 Implementation</h5></div></div></div><p> The interface of <code class="classname">tr1::shared_ptr</code> was extended for C++0x with support for rvalue-references and the other features from N2351. The <code class="classname">_Sp_counted_base</code> base class is implemented in @@ -608,7 +596,7 @@ change unless bug fixes require it. If the code that is common to both C++0x and TR1 modes needs to diverge further then it might be necessary to duplicate <code class="classname">_Sp_counted_base</code> and only make changes to the C++0x version. -</p></div><div class="section" title="Related functions and classes"><div class="titlepage"><div><div><h5 class="title"><a id="id404250"></a>Related functions and classes</h5></div></div></div><div class="variablelist"><dl><dt><span class="term"><code class="code">dynamic_pointer_cast</code>, <code class="code">static_pointer_cast</code>, +</p></div><div class="section" title="Related functions and classes"><div class="titlepage"><div><div><h5 class="title"><a id="id477695"/>Related functions and classes</h5></div></div></div><div class="variablelist"><dl><dt><span class="term"><code class="code">dynamic_pointer_cast</code>, <code class="code">static_pointer_cast</code>, <code class="code">const_pointer_cast</code></span></dt><dd><p> As noted in N2351, these functions can be implemented non-intrusively using the alias constructor. However the aliasing constructor is only available @@ -641,13 +629,13 @@ is called. Users should not try to use this. As well as the extra constructors, this implementation also needs some members of _Sp_counted_deleter to be protected where they could otherwise be private. - </p></dd></dl></div></div></div><div class="section" title="Use"><div class="titlepage"><div><div><h4 class="title"><a id="shared_ptr.using"></a>Use</h4></div></div></div><div class="section" title="Examples"><div class="titlepage"><div><div><h5 class="title"><a id="id478086"></a>Examples</h5></div></div></div><p> + </p></dd></dl></div></div></div><div class="section" title="Use"><div class="titlepage"><div><div><h4 class="title"><a id="shared_ptr.using"/>Use</h4></div></div></div><div class="section" title="Examples"><div class="titlepage"><div><div><h5 class="title"><a id="id477844"/>Examples</h5></div></div></div><p> Examples of use can be found in the testsuite, under <code class="filename">testsuite/tr1/2_general_utilities/shared_ptr</code>, <code class="filename">testsuite/20_util/shared_ptr</code> and <code class="filename">testsuite/20_util/weak_ptr</code>. - </p></div><div class="section" title="Unresolved Issues"><div class="titlepage"><div><div><h5 class="title"><a id="id397929"></a>Unresolved Issues</h5></div></div></div><p> + </p></div><div class="section" title="Unresolved Issues"><div class="titlepage"><div><div><h5 class="title"><a id="id477874"/>Unresolved Issues</h5></div></div></div><p> The <span class="emphasis"><em><code class="classname">shared_ptr</code> atomic access</em></span> clause in the C++0x working draft is not implemented in GCC. </p><p> @@ -683,41 +671,29 @@ be private. </p><p> tr1::_Sp_deleter could be a private member of tr1::__shared_count but it would alter the ABI. - </p></div></div><div class="section" title="Acknowledgments"><div class="titlepage"><div><div><h4 class="title"><a id="shared_ptr.ack"></a>Acknowledgments</h4></div></div></div><p> + </p></div></div><div class="section" title="Acknowledgments"><div class="titlepage"><div><div><h4 class="title"><a id="shared_ptr.ack"/>Acknowledgments</h4></div></div></div><p> The original authors of the Boost shared_ptr, which is really nice code to work with, Peter Dimov in particular for his help and invaluable advice on thread safety. Phillip Jordan and Paolo Carlini for the lock policy implementation. - </p></div><div class="bibliography" title="Bibliography"><div class="titlepage"><div><div><h4 class="title"><a id="shared_ptr.biblio"></a>Bibliography</h4></div></div></div><div class="biblioentry"><a id="id444231"></a><p><span class="biblioid"> - <a class="ulink" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2351.htm" target="_top"> - <em class="citetitle"> - Improving shared_ptr for C++0x, Revision 2 - </em> - </a> - . </span><span class="subtitle"> + </p></div><div class="bibliography" title="Bibliography"><div class="titlepage"><div><div><h4 class="title"><a id="shared_ptr.biblio"/>Bibliography</h4></div></div></div><div class="biblioentry"><a id="id477967"/><p><span class="biblioid"> + . </span><span class="citetitle"><em class="citetitle"> + Improving shared_ptr for C++0x, Revision 2 + </em>. </span><span class="subtitle"> N2351 - . </span></p></div><div class="biblioentry"><a id="id444254"></a><p><span class="biblioid"> - <a class="ulink" href="http://open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2456.html" target="_top"> - <em class="citetitle"> - C++ Standard Library Active Issues List - </em> - </a> - . </span><span class="subtitle"> + . </span></p></div><div class="biblioentry"><a id="id477989"/><p><span class="biblioid"> + . </span><span class="citetitle"><em class="citetitle"> + C++ Standard Library Active Issues List + </em>. </span><span class="subtitle"> N2456 - . </span></p></div><div class="biblioentry"><a id="id400755"></a><p><span class="biblioid"> - <a class="ulink" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2461.pdf" target="_top"> - <em class="citetitle"> - Working Draft, Standard for Programming Language C++ - </em> - </a> - . </span><span class="subtitle"> + . </span></p></div><div class="biblioentry"><a id="id478010"/><p><span class="biblioid"> + . </span><span class="citetitle"><em class="citetitle"> + Working Draft, Standard for Programming Language C++ + </em>. </span><span class="subtitle"> N2461 - . </span></p></div><div class="biblioentry"><a id="id424141"></a><p><span class="biblioid"> - <a class="ulink" href="http://boost.org/libs/smart_ptr/shared_ptr.htm" target="_top">shared_ptr - <em class="citetitle"> - Boost C++ Libraries documentation, shared_ptr - </em> - </a> - . </span><span class="subtitle"> + . </span></p></div><div class="biblioentry"><a id="id478032"/><p><span class="biblioid">shared_ptr + . </span><span class="citetitle"><em class="citetitle"> + Boost C++ Libraries documentation, shared_ptr + </em>. </span><span class="subtitle"> N2461 - . </span></p></div></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pairs.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="utilities.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="traits.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Pairs </td><td width="20%" align="center"><a accesskey="h" href="../spine.html">Home</a></td><td width="40%" align="right" valign="top"> Traits</td></tr></table></div></body></html> + . </span></p></div></div></div></div><div class="navfooter"><hr/><table width="100%" summary="Navigation footer"><tr><td align="left"><a accesskey="p" href="pairs.html">Prev</a> </td><td align="center"><a accesskey="u" href="utilities.html">Up</a></td><td align="right"> <a accesskey="n" href="traits.html">Next</a></td></tr><tr><td align="left" valign="top">Pairs </td><td align="center"><a accesskey="h" href="../spine.html">Home</a></td><td align="right" valign="top"> Traits</td></tr></table></div></body></html> |