[prev in list] [next in list] [prev in thread] [next in thread]
List: boost-users
Subject: [Boost-users] Which is the effective way for data transfer for Interprocess shared memory ?
From: Kalyan Chakravarthy Gudimella <kalyan.gudimella () gmail ! com>
Date: 2015-04-22 15:20:20
Message-ID: CAAYAmVdmjjHXuKkqcBuUrOVXkzieTJFCowcuTOzAs-BmnLbftw () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi,
I am currently evaluating boost interprocess library for using shared
memory.
I found two ways to transfer complex data structures.
1. Creating data structures directly in shared memory.
E.g.
http://www.boost.org/doc/libs/1_58_0/doc/html/interprocess/allocators_containers.html#interprocess.allocators_containers.containers_explained.containers_of_containers
class complex_data{
int id_;
char_string char_string_;
int_vector_vector int_vector_vector_;
public:
//Since void_allocator is convertible to any other allocator<T>, we
can simplify
//the initialization taking just one allocator for all inner containers.
complex_data(int id, const char *name, const void_allocator &void_alloc)
: id_(id), char_string_(name, void_alloc), int_vector_vector_(void_alloc)
{}
//Other members...};
2. Serializing data into bufferstream and deserializing it.
E.g.http://www.boost.org/doc/libs/1_58_0/doc/html/interprocess/streams.html
My initial trial shows that streaming to bufferstream took 7 times more
time than using direct shared structures.
Can you please help me to choose the effective way between these two
approaches?
thanks,
Kalyan
[Attachment #5 (text/html)]
<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.htm \
l#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<T>, 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)">&</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>
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic