Boost logo

Boost Users :

Subject: Re: [Boost-users] [Interprocess] Different outputs under bash and gdb
From: Aditya Gadre (agadre_at_[hidden])
Date: 2010-11-24 09:21:25


Ion,

Thank you for your reply. According to Boost.Interprocess documentation,
you *can* share std::vector by using managed shared memory and
Boost.Interprocess allocator (please see "Creating vectors in shared
memory" in "Quick guide for the impatient" in Boost.Interprocess
documentation). Following those guidelines and the example therein , I
have successfully shared std::vector object using following -

using boost::interprocess;
typedef allocator<float, managed_shared_memory::segment_manager>
ShmAllocator_float;
typedef std::vector<float, ShmAllocator_float> MyVector;
managed_shared_memory segment(create_only, "MySharedVector", 10000);
const ShmAllocator_float alloc(segment.get_segment_manager());
MyVector* pvec = segment.construct<MyVector>("MyVector")(alloc);

- Aditya

On 11/24/2010 04:47 AM, Ion Gaztañaga wrote:
> On 23/11/2010 22:23, Aditya Gadre wrote:
>> Dear all,
>>
>> I have a question about proper use of Boost.Interprocess for sharing
>> custom C++ classes. I recently started using Boost.Interprocess and have
>> been successful in sharing boost::array, std::vector<float>,
>> std::vector< boost::array<float, 2> > etc using
>> boost::interprocess::managed_shared_memory and
>> boost::interprocess::allocator.
>
> You can't share std::vector, it contains raw pointers. You must use
> boost::interprocess:vector with boost::interprocess::allocator.
>
> Best,
>
> ion
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net