Boost logo

Boost Users :

From: Pataki Szilard (ceelurd_at_[hidden])
Date: 2006-10-14 08:45:33


Hello!

I'm having trouble porting my application from boost.shmem to
boost.interprocess. Here are my typedefs:

//--------------------
typedef std::pair<
                        const int,
                        MyNode>
                MyPair;
                
typedef boost::interprocess::allocator <
                        MyPair,
                        boost::interprocess::managed_shared_memory::segment_manager>
                MyAlloc;

typedef boost::interprocess::multimap<
                        const int,
                        MyNode,
                        std::less<const int>,
                        MyAlloc>
                MyMap;
                
typedef MyMap::iterator MyMapIterator;
//--------------------

In the first process I do:
//--------------------
boost::interprocess::shared_memory_object::remove(SEGMENT_NAME);
boost::interprocess::managed_shared_memory
segment(boost::interprocess::create_only, SEGMENT_NAME, SEGMENT_SIZE);

MyAlloc myAlloc(segment.get_segment_manager());
std::less<const int> myComparator;
MyMap* myMap = segment.construct<MyMap>(MAP_NAME)(myComparator, myAlloc);
//--------------------

In the second process I do:
//--------------------
boost::interprocess::managed_shared_memory
segment(boost::interprocess::open_only, SEGMENT_NAME);
MyMap* myMap = segment.find<MyMap>(MAP_NAME).first;

MyMapIterator it = myMap->begin(); // <- CRASHES HERE!
for ( ; it != myMap->end; it++)
{
        //...
}
//--------------------

The myMap pointer in the second process is not NULL, it has the same
value as in the first process. Everything worked fine with
boost.shmem. Anybody got a clue, what is wrong here and what is so
different between how boost.shmem and boost.inteprocess perform these
operations?

Can boost.shmem and boost.interprocess coexist? If I'm stuck with
boost.shmem for storing the map in shared memory, can I still use an
upgradable mutex from boost.interprocess?

Thanks,
Szilard


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