1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>Quick Guide for the Impatient</title> 6<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> 7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 8<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> 9<link rel="up" href="../interprocess.html" title="Chapter 18. Boost.Interprocess"> 10<link rel="prev" href="../interprocess.html" title="Chapter 18. Boost.Interprocess"> 11<link rel="next" href="some_basic_explanations.html" title="Some basic explanations"> 12</head> 13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 14<table cellpadding="2" width="100%"><tr> 15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> 16<td align="center"><a href="../../../index.html">Home</a></td> 17<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> 18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 20<td align="center"><a href="../../../more/index.htm">More</a></td> 21</tr></table> 22<hr> 23<div class="spirit-nav"> 24<a accesskey="p" href="../interprocess.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interprocess.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="some_basic_explanations.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="section"> 27<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 28<a name="interprocess.quick_guide"></a><a class="link" href="quick_guide.html" title="Quick Guide for the Impatient">Quick Guide for the Impatient</a> 29</h2></div></div></div> 30<div class="toc"><dl class="toc"> 31<dt><span class="section"><a href="quick_guide.html#interprocess.quick_guide.qg_memory_pool">Using shared 32 memory as a pool of unnamed memory blocks</a></span></dt> 33<dt><span class="section"><a href="quick_guide.html#interprocess.quick_guide.qg_named_interprocess">Creating 34 named shared memory objects</a></span></dt> 35<dt><span class="section"><a href="quick_guide.html#interprocess.quick_guide.qg_offset_ptr">Using an offset 36 smart pointer for shared memory</a></span></dt> 37<dt><span class="section"><a href="quick_guide.html#interprocess.quick_guide.qg_interprocess_container">Creating 38 vectors in shared memory</a></span></dt> 39<dt><span class="section"><a href="quick_guide.html#interprocess.quick_guide.qg_interprocess_map">Creating 40 maps in shared memory</a></span></dt> 41</dl></div> 42<div class="section"> 43<div class="titlepage"><div><div><h3 class="title"> 44<a name="interprocess.quick_guide.qg_memory_pool"></a><a class="link" href="quick_guide.html#interprocess.quick_guide.qg_memory_pool" title="Using shared memory as a pool of unnamed memory blocks">Using shared 45 memory as a pool of unnamed memory blocks</a> 46</h3></div></div></div> 47<p> 48 You can just allocate a portion of a shared memory segment, copy the message 49 to that buffer, send the offset of that portion of shared memory to another 50 process, and you are done. Let's see the example: 51 </p> 52<p> 53</p> 54<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">managed_shared_memory</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 55<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cstdlib</span><span class="special">></span> <span class="comment">//std::system</span> 56<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">sstream</span><span class="special">></span> 57 58<span class="keyword">int</span> <span class="identifier">main</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">argv</span><span class="special">[])</span> 59<span class="special">{</span> 60 <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">interprocess</span><span class="special">;</span> 61 <span class="keyword">if</span><span class="special">(</span><span class="identifier">argc</span> <span class="special">==</span> <span class="number">1</span><span class="special">){</span> <span class="comment">//Parent process</span> 62 <span class="comment">//Remove shared memory on construction and destruction</span> 63 <span class="keyword">struct</span> <span class="identifier">shm_remove</span> 64 <span class="special">{</span> 65 <span class="identifier">shm_remove</span><span class="special">()</span> <span class="special">{</span> <span class="identifier">shared_memory_object</span><span class="special">::</span><span class="identifier">remove</span><span class="special">(</span><span class="string">"MySharedMemory"</span><span class="special">);</span> <span class="special">}</span> 66 <span class="special">~</span><span class="identifier">shm_remove</span><span class="special">(){</span> <span class="identifier">shared_memory_object</span><span class="special">::</span><span class="identifier">remove</span><span class="special">(</span><span class="string">"MySharedMemory"</span><span class="special">);</span> <span class="special">}</span> 67 <span class="special">}</span> <span class="identifier">remover</span><span class="special">;</span> 68 69 <span class="comment">//Create a managed shared memory segment</span> 70 <span class="identifier">managed_shared_memory</span> <span class="identifier">segment</span><span class="special">(</span><span class="identifier">create_only</span><span class="special">,</span> <span class="string">"MySharedMemory"</span><span class="special">,</span> <span class="number">65536</span><span class="special">);</span> 71 72 <span class="comment">//Allocate a portion of the segment (raw memory)</span> 73 <span class="identifier">managed_shared_memory</span><span class="special">::</span><span class="identifier">size_type</span> <span class="identifier">free_memory</span> <span class="special">=</span> <span class="identifier">segment</span><span class="special">.</span><span class="identifier">get_free_memory</span><span class="special">();</span> 74 <span class="keyword">void</span> <span class="special">*</span> <span class="identifier">shptr</span> <span class="special">=</span> <span class="identifier">segment</span><span class="special">.</span><span class="identifier">allocate</span><span class="special">(</span><span class="number">1024</span><span class="comment">/*bytes to allocate*/</span><span class="special">);</span> 75 76 <span class="comment">//Check invariant</span> 77 <span class="keyword">if</span><span class="special">(</span><span class="identifier">free_memory</span> <span class="special"><=</span> <span class="identifier">segment</span><span class="special">.</span><span class="identifier">get_free_memory</span><span class="special">())</span> 78 <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> 79 80 <span class="comment">//An handle from the base address can identify any byte of the shared</span> 81 <span class="comment">//memory segment even if it is mapped in different base addresses</span> 82 <span class="identifier">managed_shared_memory</span><span class="special">::</span><span class="identifier">handle_t</span> <span class="identifier">handle</span> <span class="special">=</span> <span class="identifier">segment</span><span class="special">.</span><span class="identifier">get_handle_from_address</span><span class="special">(</span><span class="identifier">shptr</span><span class="special">);</span> 83 <span class="identifier">std</span><span class="special">::</span><span class="identifier">stringstream</span> <span class="identifier">s</span><span class="special">;</span> 84 <span class="identifier">s</span> <span class="special"><<</span> <span class="identifier">argv</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special"><<</span> <span class="string">" "</span> <span class="special"><<</span> <span class="identifier">handle</span><span class="special">;</span> 85 <span class="identifier">s</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">ends</span><span class="special">;</span> 86 <span class="comment">//Launch child process</span> 87 <span class="keyword">if</span><span class="special">(</span><span class="number">0</span> <span class="special">!=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">system</span><span class="special">(</span><span class="identifier">s</span><span class="special">.</span><span class="identifier">str</span><span class="special">().</span><span class="identifier">c_str</span><span class="special">()))</span> 88 <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> 89 <span class="comment">//Check memory has been freed</span> 90 <span class="keyword">if</span><span class="special">(</span><span class="identifier">free_memory</span> <span class="special">!=</span> <span class="identifier">segment</span><span class="special">.</span><span class="identifier">get_free_memory</span><span class="special">())</span> 91 <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> 92 <span class="special">}</span> 93 <span class="keyword">else</span><span class="special">{</span> 94 <span class="comment">//Open managed segment</span> 95 <span class="identifier">managed_shared_memory</span> <span class="identifier">segment</span><span class="special">(</span><span class="identifier">open_only</span><span class="special">,</span> <span class="string">"MySharedMemory"</span><span class="special">);</span> 96 97 <span class="comment">//An handle from the base address can identify any byte of the shared</span> 98 <span class="comment">//memory segment even if it is mapped in different base addresses</span> 99 <span class="identifier">managed_shared_memory</span><span class="special">::</span><span class="identifier">handle_t</span> <span class="identifier">handle</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> 100 101 <span class="comment">//Obtain handle value</span> 102 <span class="identifier">std</span><span class="special">::</span><span class="identifier">stringstream</span> <span class="identifier">s</span><span class="special">;</span> <span class="identifier">s</span> <span class="special"><<</span> <span class="identifier">argv</span><span class="special">[</span><span class="number">1</span><span class="special">];</span> <span class="identifier">s</span> <span class="special">>></span> <span class="identifier">handle</span><span class="special">;</span> 103 104 <span class="comment">//Get buffer local address from handle</span> 105 <span class="keyword">void</span> <span class="special">*</span><span class="identifier">msg</span> <span class="special">=</span> <span class="identifier">segment</span><span class="special">.</span><span class="identifier">get_address_from_handle</span><span class="special">(</span><span class="identifier">handle</span><span class="special">);</span> 106 107 <span class="comment">//Deallocate previously allocated memory</span> 108 <span class="identifier">segment</span><span class="special">.</span><span class="identifier">deallocate</span><span class="special">(</span><span class="identifier">msg</span><span class="special">);</span> 109 <span class="special">}</span> 110 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 111<span class="special">}</span> 112</pre> 113<p> 114 </p> 115</div> 116<div class="section"> 117<div class="titlepage"><div><div><h3 class="title"> 118<a name="interprocess.quick_guide.qg_named_interprocess"></a><a class="link" href="quick_guide.html#interprocess.quick_guide.qg_named_interprocess" title="Creating named shared memory objects">Creating 119 named shared memory objects</a> 120</h3></div></div></div> 121<p> 122 You want to create objects in a shared memory segment, giving a string name 123 to them so that any other process can find, use and delete them from the 124 segment when the objects are not needed anymore. Example: 125 </p> 126<p> 127</p> 128<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">managed_shared_memory</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 129<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cstdlib</span><span class="special">></span> <span class="comment">//std::system</span> 130<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cstddef</span><span class="special">></span> 131<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> 132<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">utility</span><span class="special">></span> 133 134<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">argv</span><span class="special">[])</span> 135<span class="special">{</span> 136 <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">interprocess</span><span class="special">;</span> 137 <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="keyword">double</span><span class="special">,</span> <span class="keyword">int</span><span class="special">></span> <span class="identifier">MyType</span><span class="special">;</span> 138 139 <span class="keyword">if</span><span class="special">(</span><span class="identifier">argc</span> <span class="special">==</span> <span class="number">1</span><span class="special">){</span> <span class="comment">//Parent process</span> 140 <span class="comment">//Remove shared memory on construction and destruction</span> 141 <span class="keyword">struct</span> <span class="identifier">shm_remove</span> 142 <span class="special">{</span> 143 <span class="identifier">shm_remove</span><span class="special">()</span> <span class="special">{</span> <span class="identifier">shared_memory_object</span><span class="special">::</span><span class="identifier">remove</span><span class="special">(</span><span class="string">"MySharedMemory"</span><span class="special">);</span> <span class="special">}</span> 144 <span class="special">~</span><span class="identifier">shm_remove</span><span class="special">(){</span> <span class="identifier">shared_memory_object</span><span class="special">::</span><span class="identifier">remove</span><span class="special">(</span><span class="string">"MySharedMemory"</span><span class="special">);</span> <span class="special">}</span> 145 <span class="special">}</span> <span class="identifier">remover</span><span class="special">;</span> 146 147 <span class="comment">//Construct managed shared memory</span> 148 <span class="identifier">managed_shared_memory</span> <span class="identifier">segment</span><span class="special">(</span><span class="identifier">create_only</span><span class="special">,</span> <span class="string">"MySharedMemory"</span><span class="special">,</span> <span class="number">65536</span><span class="special">);</span> 149 150 <span class="comment">//Create an object of MyType initialized to {0.0, 0}</span> 151 <span class="identifier">MyType</span> <span class="special">*</span><span class="identifier">instance</span> <span class="special">=</span> <span class="identifier">segment</span><span class="special">.</span><span class="identifier">construct</span><span class="special"><</span><span class="identifier">MyType</span><span class="special">></span> 152 <span class="special">(</span><span class="string">"MyType instance"</span><span class="special">)</span> <span class="comment">//name of the object</span> 153 <span class="special">(</span><span class="number">0.0</span><span class="special">,</span> <span class="number">0</span><span class="special">);</span> <span class="comment">//ctor first argument</span> 154 155 <span class="comment">//Create an array of 10 elements of MyType initialized to {0.0, 0}</span> 156 <span class="identifier">MyType</span> <span class="special">*</span><span class="identifier">array</span> <span class="special">=</span> <span class="identifier">segment</span><span class="special">.</span><span class="identifier">construct</span><span class="special"><</span><span class="identifier">MyType</span><span class="special">></span> 157 <span class="special">(</span><span class="string">"MyType array"</span><span class="special">)</span> <span class="comment">//name of the object</span> 158 <span class="special">[</span><span class="number">10</span><span class="special">]</span> <span class="comment">//number of elements</span> 159 <span class="special">(</span><span class="number">0.0</span><span class="special">,</span> <span class="number">0</span><span class="special">);</span> <span class="comment">//Same two ctor arguments for all objects</span> 160 161 <span class="comment">//Create an array of 3 elements of MyType initializing each one</span> 162 <span class="comment">//to a different value {0.0, 0}, {1.0, 1}, {2.0, 2}...</span> 163 <span class="keyword">float</span> <span class="identifier">float_initializer</span><span class="special">[</span><span class="number">3</span><span class="special">]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">0.0</span><span class="special">,</span> <span class="number">1.0</span><span class="special">,</span> <span class="number">2.0</span> <span class="special">};</span> 164 <span class="keyword">int</span> <span class="identifier">int_initializer</span><span class="special">[</span><span class="number">3</span><span class="special">]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">0</span><span class="special">,</span> <span class="number">1</span><span class="special">,</span> <span class="number">2</span> <span class="special">};</span> 165 166 <span class="identifier">MyType</span> <span class="special">*</span><span class="identifier">array_it</span> <span class="special">=</span> <span class="identifier">segment</span><span class="special">.</span><span class="identifier">construct_it</span><span class="special"><</span><span class="identifier">MyType</span><span class="special">></span> 167 <span class="special">(</span><span class="string">"MyType array from it"</span><span class="special">)</span> <span class="comment">//name of the object</span> 168 <span class="special">[</span><span class="number">3</span><span class="special">]</span> <span class="comment">//number of elements</span> 169 <span class="special">(</span> <span class="special">&</span><span class="identifier">float_initializer</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="comment">//Iterator for the 1st ctor argument</span> 170 <span class="special">,</span> <span class="special">&</span><span class="identifier">int_initializer</span><span class="special">[</span><span class="number">0</span><span class="special">]);</span> <span class="comment">//Iterator for the 2nd ctor argument</span> 171 172 <span class="comment">//Launch child process</span> 173 <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">s</span><span class="special">(</span><span class="identifier">argv</span><span class="special">[</span><span class="number">0</span><span class="special">]);</span> <span class="identifier">s</span> <span class="special">+=</span> <span class="string">" child "</span><span class="special">;</span> 174 <span class="keyword">if</span><span class="special">(</span><span class="number">0</span> <span class="special">!=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">system</span><span class="special">(</span><span class="identifier">s</span><span class="special">.</span><span class="identifier">c_str</span><span class="special">()))</span> 175 <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> 176 177 178 <span class="comment">//Check child has destroyed all objects</span> 179 <span class="keyword">if</span><span class="special">(</span><span class="identifier">segment</span><span class="special">.</span><span class="identifier">find</span><span class="special"><</span><span class="identifier">MyType</span><span class="special">>(</span><span class="string">"MyType array"</span><span class="special">).</span><span class="identifier">first</span> <span class="special">||</span> 180 <span class="identifier">segment</span><span class="special">.</span><span class="identifier">find</span><span class="special"><</span><span class="identifier">MyType</span><span class="special">>(</span><span class="string">"MyType instance"</span><span class="special">).</span><span class="identifier">first</span> <span class="special">||</span> 181 <span class="identifier">segment</span><span class="special">.</span><span class="identifier">find</span><span class="special"><</span><span class="identifier">MyType</span><span class="special">>(</span><span class="string">"MyType array from it"</span><span class="special">).</span><span class="identifier">first</span><span class="special">)</span> 182 <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> 183 <span class="special">}</span> 184 <span class="keyword">else</span><span class="special">{</span> 185 <span class="comment">//Open managed shared memory</span> 186 <span class="identifier">managed_shared_memory</span> <span class="identifier">segment</span><span class="special">(</span><span class="identifier">open_only</span><span class="special">,</span> <span class="string">"MySharedMemory"</span><span class="special">);</span> 187 188 <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">MyType</span><span class="special">*,</span> <span class="identifier">managed_shared_memory</span><span class="special">::</span><span class="identifier">size_type</span><span class="special">></span> <span class="identifier">res</span><span class="special">;</span> 189 190 <span class="comment">//Find the array</span> 191 <span class="identifier">res</span> <span class="special">=</span> <span class="identifier">segment</span><span class="special">.</span><span class="identifier">find</span><span class="special"><</span><span class="identifier">MyType</span><span class="special">></span> <span class="special">(</span><span class="string">"MyType array"</span><span class="special">);</span> 192 <span class="comment">//Length should be 10</span> 193 <span class="keyword">if</span><span class="special">(</span><span class="identifier">res</span><span class="special">.</span><span class="identifier">second</span> <span class="special">!=</span> <span class="number">10</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> 194 195 <span class="comment">//Find the object</span> 196 <span class="identifier">res</span> <span class="special">=</span> <span class="identifier">segment</span><span class="special">.</span><span class="identifier">find</span><span class="special"><</span><span class="identifier">MyType</span><span class="special">></span> <span class="special">(</span><span class="string">"MyType instance"</span><span class="special">);</span> 197 <span class="comment">//Length should be 1</span> 198 <span class="keyword">if</span><span class="special">(</span><span class="identifier">res</span><span class="special">.</span><span class="identifier">second</span> <span class="special">!=</span> <span class="number">1</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> 199 200 <span class="comment">//Find the array constructed from iterators</span> 201 <span class="identifier">res</span> <span class="special">=</span> <span class="identifier">segment</span><span class="special">.</span><span class="identifier">find</span><span class="special"><</span><span class="identifier">MyType</span><span class="special">></span> <span class="special">(</span><span class="string">"MyType array from it"</span><span class="special">);</span> 202 <span class="comment">//Length should be 3</span> 203 <span class="keyword">if</span><span class="special">(</span><span class="identifier">res</span><span class="special">.</span><span class="identifier">second</span> <span class="special">!=</span> <span class="number">3</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> 204 205 <span class="comment">//We're done, delete all the objects</span> 206 <span class="identifier">segment</span><span class="special">.</span><span class="identifier">destroy</span><span class="special"><</span><span class="identifier">MyType</span><span class="special">>(</span><span class="string">"MyType array"</span><span class="special">);</span> 207 <span class="identifier">segment</span><span class="special">.</span><span class="identifier">destroy</span><span class="special"><</span><span class="identifier">MyType</span><span class="special">>(</span><span class="string">"MyType instance"</span><span class="special">);</span> 208 <span class="identifier">segment</span><span class="special">.</span><span class="identifier">destroy</span><span class="special"><</span><span class="identifier">MyType</span><span class="special">>(</span><span class="string">"MyType array from it"</span><span class="special">);</span> 209 <span class="special">}</span> 210 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 211<span class="special">}</span> 212</pre> 213<p> 214 </p> 215</div> 216<div class="section"> 217<div class="titlepage"><div><div><h3 class="title"> 218<a name="interprocess.quick_guide.qg_offset_ptr"></a><a class="link" href="quick_guide.html#interprocess.quick_guide.qg_offset_ptr" title="Using an offset smart pointer for shared memory">Using an offset 219 smart pointer for shared memory</a> 220</h3></div></div></div> 221<p> 222 <span class="bold"><strong>Boost.Interprocess</strong></span> offers offset_ptr smart 223 pointer family as an offset pointer that stores the distance between the 224 address of the offset pointer itself and the address of the pointed object. 225 When offset_ptr is placed in a shared memory segment, it can point safely 226 objects stored in the same shared memory segment, even if the segment is 227 mapped in different base addresses in different processes. 228 </p> 229<p> 230 This allows placing objects with pointer members in shared memory. For example, 231 if we want to create a linked list in shared memory: 232 </p> 233<p> 234</p> 235<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">managed_shared_memory</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 236<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">offset_ptr</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 237 238<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">interprocess</span><span class="special">;</span> 239 240<span class="comment">//Shared memory linked list node</span> 241<span class="keyword">struct</span> <span class="identifier">list_node</span> 242<span class="special">{</span> 243 <span class="identifier">offset_ptr</span><span class="special"><</span><span class="identifier">list_node</span><span class="special">></span> <span class="identifier">next</span><span class="special">;</span> 244 <span class="keyword">int</span> <span class="identifier">value</span><span class="special">;</span> 245<span class="special">};</span> 246 247<span class="keyword">int</span> <span class="identifier">main</span> <span class="special">()</span> 248<span class="special">{</span> 249 <span class="comment">//Remove shared memory on construction and destruction</span> 250 <span class="keyword">struct</span> <span class="identifier">shm_remove</span> 251 <span class="special">{</span> 252 <span class="identifier">shm_remove</span><span class="special">()</span> <span class="special">{</span> <span class="identifier">shared_memory_object</span><span class="special">::</span><span class="identifier">remove</span><span class="special">(</span><span class="string">"MySharedMemory"</span><span class="special">);</span> <span class="special">}</span> 253 <span class="special">~</span><span class="identifier">shm_remove</span><span class="special">(){</span> <span class="identifier">shared_memory_object</span><span class="special">::</span><span class="identifier">remove</span><span class="special">(</span><span class="string">"MySharedMemory"</span><span class="special">);</span> <span class="special">}</span> 254 <span class="special">}</span> <span class="identifier">remover</span><span class="special">;</span> 255 256 <span class="comment">//Create shared memory</span> 257 <span class="identifier">managed_shared_memory</span> <span class="identifier">segment</span><span class="special">(</span><span class="identifier">create_only</span><span class="special">,</span> 258 <span class="string">"MySharedMemory"</span><span class="special">,</span> <span class="comment">//segment name</span> 259 <span class="number">65536</span><span class="special">);</span> 260 261 <span class="comment">//Create linked list with 10 nodes in shared memory</span> 262 <span class="identifier">offset_ptr</span><span class="special"><</span><span class="identifier">list_node</span><span class="special">></span> <span class="identifier">prev</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">current</span><span class="special">,</span> <span class="identifier">first</span><span class="special">;</span> 263 264 <span class="keyword">int</span> <span class="identifier">i</span><span class="special">;</span> 265 <span class="keyword">for</span><span class="special">(</span><span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">10</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">prev</span> <span class="special">=</span> <span class="identifier">current</span><span class="special">){</span> 266 <span class="identifier">current</span> <span class="special">=</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">list_node</span><span class="special">*>(</span><span class="identifier">segment</span><span class="special">.</span><span class="identifier">allocate</span><span class="special">(</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">list_node</span><span class="special">)));</span> 267 <span class="identifier">current</span><span class="special">-></span><span class="identifier">value</span> <span class="special">=</span> <span class="identifier">i</span><span class="special">;</span> 268 <span class="identifier">current</span><span class="special">-></span><span class="identifier">next</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> 269 270 <span class="keyword">if</span><span class="special">(!</span><span class="identifier">prev</span><span class="special">)</span> 271 <span class="identifier">first</span> <span class="special">=</span> <span class="identifier">current</span><span class="special">;</span> 272 <span class="keyword">else</span> 273 <span class="identifier">prev</span><span class="special">-></span><span class="identifier">next</span> <span class="special">=</span> <span class="identifier">current</span><span class="special">;</span> 274 <span class="special">}</span> 275 276 <span class="comment">//Communicate list to other processes</span> 277 <span class="comment">//. . .</span> 278 <span class="comment">//When done, destroy list</span> 279 <span class="keyword">for</span><span class="special">(</span><span class="identifier">current</span> <span class="special">=</span> <span class="identifier">first</span><span class="special">;</span> <span class="identifier">current</span><span class="special">;</span> <span class="comment">/**/</span><span class="special">){</span> 280 <span class="identifier">prev</span> <span class="special">=</span> <span class="identifier">current</span><span class="special">;</span> 281 <span class="identifier">current</span> <span class="special">=</span> <span class="identifier">current</span><span class="special">-></span><span class="identifier">next</span><span class="special">;</span> 282 <span class="identifier">segment</span><span class="special">.</span><span class="identifier">deallocate</span><span class="special">(</span><span class="identifier">prev</span><span class="special">.</span><span class="identifier">get</span><span class="special">());</span> 283 <span class="special">}</span> 284 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 285<span class="special">}</span> 286</pre> 287<p> 288 </p> 289<p> 290 To help with basic data structures, <span class="bold"><strong>Boost.Interprocess</strong></span> 291 offers containers like vector, list, map, so you can avoid these manual data 292 structures just like with standard containers. 293 </p> 294</div> 295<div class="section"> 296<div class="titlepage"><div><div><h3 class="title"> 297<a name="interprocess.quick_guide.qg_interprocess_container"></a><a class="link" href="quick_guide.html#interprocess.quick_guide.qg_interprocess_container" title="Creating vectors in shared memory">Creating 298 vectors in shared memory</a> 299</h3></div></div></div> 300<p> 301 <span class="bold"><strong>Boost.Interprocess</strong></span> allows creating complex 302 objects in shared memory and memory mapped files. For example, we can construct 303 STL-like containers in shared memory. To do this, we just need to create 304 a special (managed) shared memory segment, declare a <span class="bold"><strong>Boost.Interprocess</strong></span> 305 allocator and construct the vector in shared memory just if it was any other 306 object. 307 </p> 308<p> 309 The class that allows this complex structures in shared memory is called 310 <code class="computeroutput"><a class="link" href="../boost/interprocess/managed_shared_memory.html" title="Type definition managed_shared_memory">boost::interprocess::managed_shared_memory</a></code> 311 and it's easy to use. Just execute this example without arguments: 312 </p> 313<p> 314</p> 315<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">managed_shared_memory</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 316<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">containers</span><span class="special">/</span><span class="identifier">vector</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 317<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">allocators</span><span class="special">/</span><span class="identifier">allocator</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 318<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">string</span><span class="special">></span> 319<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cstdlib</span><span class="special">></span> <span class="comment">//std::system</span> 320 321<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">interprocess</span><span class="special">;</span> 322 323<span class="comment">//Define an STL compatible allocator of ints that allocates from the managed_shared_memory.</span> 324<span class="comment">//This allocator will allow placing containers in the segment</span> 325<span class="keyword">typedef</span> <span class="identifier">allocator</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">managed_shared_memory</span><span class="special">::</span><span class="identifier">segment_manager</span><span class="special">></span> <span class="identifier">ShmemAllocator</span><span class="special">;</span> 326 327<span class="comment">//Alias a vector that uses the previous STL-like allocator so that allocates</span> 328<span class="comment">//its values from the segment</span> 329<span class="keyword">typedef</span> <span class="identifier">vector</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">ShmemAllocator</span><span class="special">></span> <span class="identifier">MyVector</span><span class="special">;</span> 330 331<span class="comment">//Main function. For parent process argc == 1, for child process argc == 2</span> 332<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">argv</span><span class="special">[])</span> 333<span class="special">{</span> 334 <span class="keyword">if</span><span class="special">(</span><span class="identifier">argc</span> <span class="special">==</span> <span class="number">1</span><span class="special">){</span> <span class="comment">//Parent process</span> 335 <span class="comment">//Remove shared memory on construction and destruction</span> 336 <span class="keyword">struct</span> <span class="identifier">shm_remove</span> 337 <span class="special">{</span> 338 <span class="identifier">shm_remove</span><span class="special">()</span> <span class="special">{</span> <span class="identifier">shared_memory_object</span><span class="special">::</span><span class="identifier">remove</span><span class="special">(</span><span class="string">"MySharedMemory"</span><span class="special">);</span> <span class="special">}</span> 339 <span class="special">~</span><span class="identifier">shm_remove</span><span class="special">(){</span> <span class="identifier">shared_memory_object</span><span class="special">::</span><span class="identifier">remove</span><span class="special">(</span><span class="string">"MySharedMemory"</span><span class="special">);</span> <span class="special">}</span> 340 <span class="special">}</span> <span class="identifier">remover</span><span class="special">;</span> 341 342 <span class="comment">//Create a new segment with given name and size</span> 343 <span class="identifier">managed_shared_memory</span> <span class="identifier">segment</span><span class="special">(</span><span class="identifier">create_only</span><span class="special">,</span> <span class="string">"MySharedMemory"</span><span class="special">,</span> <span class="number">65536</span><span class="special">);</span> 344 345 <span class="comment">//Initialize shared memory STL-compatible allocator</span> 346 <span class="keyword">const</span> <span class="identifier">ShmemAllocator</span> <span class="identifier">alloc_inst</span> <span class="special">(</span><span class="identifier">segment</span><span class="special">.</span><span class="identifier">get_segment_manager</span><span class="special">());</span> 347 348 <span class="comment">//Construct a vector named "MyVector" in shared memory with argument alloc_inst</span> 349 <span class="identifier">MyVector</span> <span class="special">*</span><span class="identifier">myvector</span> <span class="special">=</span> <span class="identifier">segment</span><span class="special">.</span><span class="identifier">construct</span><span class="special"><</span><span class="identifier">MyVector</span><span class="special">>(</span><span class="string">"MyVector"</span><span class="special">)(</span><span class="identifier">alloc_inst</span><span class="special">);</span> 350 351 <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="comment">//Insert data in the vector</span> 352 <span class="identifier">myvector</span><span class="special">-></span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">i</span><span class="special">);</span> 353 354 <span class="comment">//Launch child process</span> 355 <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">s</span><span class="special">(</span><span class="identifier">argv</span><span class="special">[</span><span class="number">0</span><span class="special">]);</span> <span class="identifier">s</span> <span class="special">+=</span> <span class="string">" child "</span><span class="special">;</span> 356 <span class="keyword">if</span><span class="special">(</span><span class="number">0</span> <span class="special">!=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">system</span><span class="special">(</span><span class="identifier">s</span><span class="special">.</span><span class="identifier">c_str</span><span class="special">()))</span> 357 <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> 358 359 <span class="comment">//Check child has destroyed the vector</span> 360 <span class="keyword">if</span><span class="special">(</span><span class="identifier">segment</span><span class="special">.</span><span class="identifier">find</span><span class="special"><</span><span class="identifier">MyVector</span><span class="special">>(</span><span class="string">"MyVector"</span><span class="special">).</span><span class="identifier">first</span><span class="special">)</span> 361 <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> 362 <span class="special">}</span> 363 <span class="keyword">else</span><span class="special">{</span> <span class="comment">//Child process</span> 364 <span class="comment">//Open the managed segment</span> 365 <span class="identifier">managed_shared_memory</span> <span class="identifier">segment</span><span class="special">(</span><span class="identifier">open_only</span><span class="special">,</span> <span class="string">"MySharedMemory"</span><span class="special">);</span> 366 367 <span class="comment">//Find the vector using the c-string name</span> 368 <span class="identifier">MyVector</span> <span class="special">*</span><span class="identifier">myvector</span> <span class="special">=</span> <span class="identifier">segment</span><span class="special">.</span><span class="identifier">find</span><span class="special"><</span><span class="identifier">MyVector</span><span class="special">>(</span><span class="string">"MyVector"</span><span class="special">).</span><span class="identifier">first</span><span class="special">;</span> 369 370 <span class="comment">//Use vector in reverse order</span> 371 <span class="identifier">std</span><span class="special">::</span><span class="identifier">sort</span><span class="special">(</span><span class="identifier">myvector</span><span class="special">-></span><span class="identifier">rbegin</span><span class="special">(),</span> <span class="identifier">myvector</span><span class="special">-></span><span class="identifier">rend</span><span class="special">());</span> 372 373 <span class="comment">//When done, destroy the vector from the segment</span> 374 <span class="identifier">segment</span><span class="special">.</span><span class="identifier">destroy</span><span class="special"><</span><span class="identifier">MyVector</span><span class="special">>(</span><span class="string">"MyVector"</span><span class="special">);</span> 375 <span class="special">}</span> 376 377 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 378<span class="special">}</span> 379</pre> 380<p> 381 </p> 382<p> 383 The parent process will create an special shared memory class that allows 384 easy construction of many complex data structures associated with a name. 385 The parent process executes the same program with an additional argument 386 so the child process opens the shared memory and uses the vector and erases 387 it. 388 </p> 389</div> 390<div class="section"> 391<div class="titlepage"><div><div><h3 class="title"> 392<a name="interprocess.quick_guide.qg_interprocess_map"></a><a class="link" href="quick_guide.html#interprocess.quick_guide.qg_interprocess_map" title="Creating maps in shared memory">Creating 393 maps in shared memory</a> 394</h3></div></div></div> 395<p> 396 Just like a vector, <span class="bold"><strong>Boost.Interprocess</strong></span> allows 397 creating maps in shared memory and memory mapped files. The only difference 398 is that like standard associative containers, <span class="bold"><strong>Boost.Interprocess</strong></span>'s 399 map needs also the comparison functor when an allocator is passed in the 400 constructor: 401 </p> 402<p> 403</p> 404<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">managed_shared_memory</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 405<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">containers</span><span class="special">/</span><span class="identifier">map</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 406<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">allocators</span><span class="special">/</span><span class="identifier">allocator</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 407<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">functional</span><span class="special">></span> 408<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">utility</span><span class="special">></span> 409 410<span class="keyword">int</span> <span class="identifier">main</span> <span class="special">()</span> 411<span class="special">{</span> 412 <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">interprocess</span><span class="special">;</span> 413 414 <span class="comment">//Remove shared memory on construction and destruction</span> 415 <span class="keyword">struct</span> <span class="identifier">shm_remove</span> 416 <span class="special">{</span> 417 <span class="identifier">shm_remove</span><span class="special">()</span> <span class="special">{</span> <span class="identifier">shared_memory_object</span><span class="special">::</span><span class="identifier">remove</span><span class="special">(</span><span class="string">"MySharedMemory"</span><span class="special">);</span> <span class="special">}</span> 418 <span class="special">~</span><span class="identifier">shm_remove</span><span class="special">(){</span> <span class="identifier">shared_memory_object</span><span class="special">::</span><span class="identifier">remove</span><span class="special">(</span><span class="string">"MySharedMemory"</span><span class="special">);</span> <span class="special">}</span> 419 <span class="special">}</span> <span class="identifier">remover</span><span class="special">;</span> 420 421 <span class="comment">//Shared memory front-end that is able to construct objects</span> 422 <span class="comment">//associated with a c-string. Erase previous shared memory with the name</span> 423 <span class="comment">//to be used and create the memory segment at the specified address and initialize resources</span> 424 <span class="identifier">managed_shared_memory</span> <span class="identifier">segment</span> 425 <span class="special">(</span><span class="identifier">create_only</span> 426 <span class="special">,</span><span class="string">"MySharedMemory"</span> <span class="comment">//segment name</span> 427 <span class="special">,</span><span class="number">65536</span><span class="special">);</span> <span class="comment">//segment size in bytes</span> 428 429 <span class="comment">//Note that map<Key, MappedType>'s value_type is std::pair<const Key, MappedType>,</span> 430 <span class="comment">//so the allocator must allocate that pair.</span> 431 <span class="keyword">typedef</span> <span class="keyword">int</span> <span class="identifier">KeyType</span><span class="special">;</span> 432 <span class="keyword">typedef</span> <span class="keyword">float</span> <span class="identifier">MappedType</span><span class="special">;</span> 433 <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="keyword">const</span> <span class="keyword">int</span><span class="special">,</span> <span class="keyword">float</span><span class="special">></span> <span class="identifier">ValueType</span><span class="special">;</span> 434 435 <span class="comment">//Alias an STL compatible allocator of for the map.</span> 436 <span class="comment">//This allocator will allow to place containers</span> 437 <span class="comment">//in managed shared memory segments</span> 438 <span class="keyword">typedef</span> <span class="identifier">allocator</span><span class="special"><</span><span class="identifier">ValueType</span><span class="special">,</span> <span class="identifier">managed_shared_memory</span><span class="special">::</span><span class="identifier">segment_manager</span><span class="special">></span> 439 <span class="identifier">ShmemAllocator</span><span class="special">;</span> 440 441 <span class="comment">//Alias a map of ints that uses the previous STL-like allocator.</span> 442 <span class="comment">//Note that the third parameter argument is the ordering function</span> 443 <span class="comment">//of the map, just like with std::map, used to compare the keys.</span> 444 <span class="keyword">typedef</span> <span class="identifier">map</span><span class="special"><</span><span class="identifier">KeyType</span><span class="special">,</span> <span class="identifier">MappedType</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">KeyType</span><span class="special">>,</span> <span class="identifier">ShmemAllocator</span><span class="special">></span> <span class="identifier">MyMap</span><span class="special">;</span> 445 446 <span class="comment">//Initialize the shared memory STL-compatible allocator</span> 447 <span class="identifier">ShmemAllocator</span> <span class="identifier">alloc_inst</span> <span class="special">(</span><span class="identifier">segment</span><span class="special">.</span><span class="identifier">get_segment_manager</span><span class="special">());</span> 448 449 <span class="comment">//Construct a shared memory map.</span> 450 <span class="comment">//Note that the first parameter is the comparison function,</span> 451 <span class="comment">//and the second one the allocator.</span> 452 <span class="comment">//This the same signature as std::map's constructor taking an allocator</span> 453 <span class="identifier">MyMap</span> <span class="special">*</span><span class="identifier">mymap</span> <span class="special">=</span> 454 <span class="identifier">segment</span><span class="special">.</span><span class="identifier">construct</span><span class="special"><</span><span class="identifier">MyMap</span><span class="special">>(</span><span class="string">"MyMap"</span><span class="special">)</span> <span class="comment">//object name</span> 455 <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="keyword">int</span><span class="special">>()</span> <span class="comment">//first ctor parameter</span> 456 <span class="special">,</span><span class="identifier">alloc_inst</span><span class="special">);</span> <span class="comment">//second ctor parameter</span> 457 458 <span class="comment">//Insert data in the map</span> 459 <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">){</span> 460 <span class="identifier">mymap</span><span class="special">-></span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="keyword">const</span> <span class="keyword">int</span><span class="special">,</span> <span class="keyword">float</span><span class="special">>(</span><span class="identifier">i</span><span class="special">,</span> <span class="special">(</span><span class="keyword">float</span><span class="special">)</span><span class="identifier">i</span><span class="special">));</span> 461 <span class="special">}</span> 462 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 463<span class="special">}</span> 464</pre> 465<p> 466 </p> 467<p> 468 For a more advanced example including containers of containers, see the section 469 <a class="link" href="allocators_containers.html#interprocess.allocators_containers.containers_explained.containers_of_containers" title="Containers of containers">Containers 470 of containers</a>. 471 </p> 472</div> 473</div> 474<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 475<td align="left"></td> 476<td align="right"><div class="copyright-footer">Copyright © 2005-2015 Ion Gaztanaga<p> 477 Distributed under the Boost Software License, Version 1.0. (See accompanying 478 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 479 </p> 480</div></td> 481</tr></table> 482<hr> 483<div class="spirit-nav"> 484<a accesskey="p" href="../interprocess.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interprocess.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="some_basic_explanations.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> 485</div> 486</body> 487</html> 488