<div dir="ltr">Hi,<div><br></div><div>I am currently evaluating boost interprocess library for using shared memory.</div><div><br></div><div>I found two ways to transfer complex data structures.</div><div><br></div><div>1. Creating data structures directly in shared memory.</div><div><br></div><div>E.g. <a href="http://www.boost.org/doc/libs/1_58_0/doc/html/interprocess/allocators_containers.html#interprocess.allocators_containers.containers_explained.containers_of_containers">http://www.boost.org/doc/libs/1_58_0/doc/html/interprocess/allocators_containers.html#interprocess.allocators_containers.containers_explained.containers_of_containers</a><br></div><div><br></div><div><pre class="" style="font-size:9pt;margin:1pc 62.03125px 0pc;padding:0.5pc;border:1px solid rgb(220,220,220);color:rgb(0,0,0)"><span class="" style="color:rgb(0,0,170)">class</span> <span class="">complex_data</span>
<span class="" style="color:rgb(112,112,112)">{</span>
   <span class="" style="color:rgb(0,0,170)">int</span>               <span class="">id_</span><span class="" style="color:rgb(112,112,112)">;</span>
   <span class="">char_string</span>       <span class="">char_string_</span><span class="" style="color:rgb(112,112,112)">;</span>
   <span class="">int_vector_vector</span> <span class="">int_vector_vector_</span><span class="" style="color:rgb(112,112,112)">;</span>

   <span class="" style="color:rgb(0,0,170)">public</span><span class="" style="color:rgb(112,112,112)">:</span>
   <span class="" style="color:rgb(128,0,0)">//Since void_allocator is convertible to any other allocator&lt;T&gt;, we can simplify</span>
   <span class="" style="color:rgb(128,0,0)">//the initialization taking just one allocator for all inner containers.</span>
   <span class="">complex_data</span><span class="" style="color:rgb(112,112,112)">(</span><span class="" style="color:rgb(0,0,170)">int</span> <span class="">id</span><span class="" style="color:rgb(112,112,112)">,</span> <span class="" style="color:rgb(0,0,170)">const</span> <span class="" style="color:rgb(0,0,170)">char</span> <span class="" style="color:rgb(112,112,112)">*</span><span class="">name</span><span class="" style="color:rgb(112,112,112)">,</span> <span class="" style="color:rgb(0,0,170)">const</span> <span class="">void_allocator</span> <span class="" style="color:rgb(112,112,112)">&amp;</span><span class="">void_alloc</span><span class="" style="color:rgb(112,112,112)">)</span>
      <span class="" style="color:rgb(112,112,112)">:</span> <span class="">id_</span><span class="" style="color:rgb(112,112,112)">(</span><span class="">id</span><span class="" style="color:rgb(112,112,112)">),</span> <span class="">char_string_</span><span class="" style="color:rgb(112,112,112)">(</span><span class="">name</span><span class="" style="color:rgb(112,112,112)">,</span> <span class="">void_alloc</span><span class="" style="color:rgb(112,112,112)">),</span> <span class="">int_vector_vector_</span><span class="" style="color:rgb(112,112,112)">(</span><span class="">void_alloc</span><span class="" style="color:rgb(112,112,112)">)</span>
   <span class="" style="color:rgb(112,112,112)">{}</span>
   <span class="" style="color:rgb(128,0,0)">//Other members...</span>
<span class="" style="color:rgb(112,112,112)">};</span></pre></div><div><br></div><div>2. Serializing data into bufferstream and deserializing it.</div><div><br></div><div>E.g.<a href="http://www.boost.org/doc/libs/1_58_0/doc/html/interprocess/streams.html">http://www.boost.org/doc/libs/1_58_0/doc/html/interprocess/streams.html</a></div><div><br></div><div><br></div><div>My initial trial shows that streaming to bufferstream took 7 times more time than using direct shared structures.</div><div><br></div><div>Can you please help me to choose the effective way between these two approaches?</div><div><br></div><div>thanks,</div><div>Kalyan</div></div>