Boost logo

Boost Users :

Subject: [Boost-users] Definition of string in shared memory
From: Samuel Gallard (samuel.gallard_at_[hidden])
Date: 2009-07-20 09:29:02


Hello,

I can't useful examples about how to store string in shared memory.

I have to share a queue of Element objects (queue<Element> *) between
processes.

This is the signature of Element class :

class Element
{
    ...
    private :
        string dir;

        string file;
    ...
}

I used a shared_memory_object to use the queue. When I test it with
thread, it is working fine.

But when i test it with process, I obtained some segmentation fault
because it can't retrieve the attributes for an Element object. it is
normal because I am creating the Element object in one process the
second can't access it.

I have seen in boost documentation the template
interprocess:basic_string. But I have no clue how to use it.

I would like to have something like :

typedef basic_string< string, segment> mystring

class Element
{
    ...
    private :
        mystring dir;

        mystring file;
    ...
}

Could you someone show me how to do that in the creation but also in the
implementation.

Thanks you in advance

Regards

Samuel
  


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