Boost logo

Boost Users :

Subject: [Boost-users] question on boost::interprocess
From: Markos.Perrakis_at_[hidden]
Date: 2008-10-22 16:21:10

I have created a shared memory segment with the boost::interprocess
library and have created and populated a boost::interprocess::map in that
segment. The key for the map is the boost::interprocess::string class.

If I want to search for an element in the map I obviously have to supply
the key for the element. Here is what I do:

        std::string key;
        // assign here a value to key string object

        const Char_Alloc char_alloc(
(shared_memory_segment_obj.get_segment_manager() ) );
        boost::interprocess::string some_string( char_alloc );

        some_string.assign( key.c_str() );

where Char_Alloc is a suitable shared memory allocator for plain

As you can see from the code the key (the some_string object) for the map
is created in local memory (in-process memory) but the contents of the
string are allocated in shared memory.

If two threads access this shared memory segment and execute the above
code at the same time, is this thread safe? Will the two concurrent
assign() statements use the same location in shared memory and cause
overlaps? Or is the shared memory allocator smart enough to synchronize
the two assign() calls and execute them sequencially?

In case the shared memory allocator is not smart enough to guarantee
synchronization can I use a boost::interprocess mutex for thread

Markos Perrakis

This e-mail, including all materials contained in or attached to this e-mail, contains proprietary and confidential information solely for the internal use of the intended recipient. If you have received this email in error, please notify us immediately by return e-mail or otherwise and ensure that it is permanently deleted from your systems, and do not print, copy, distribute or read its contents.

Le présent courriel, y compris tous les documents qu'il contient ou qui y sont joints, renferme des renseignements exclusifs et confidentiels destinés uniquement à l'usage interne du destinataire prévu. Si vous avez reçu le présent courriel par erreur, veuillez nous aviser immédiatement, notamment par retour de courriel, et vous assurer qu'il est supprimé de façon permanente de vos systèmes; veuillez également vous abstenir d'imprimer, de copier, de distribuer ou de lire son contenu.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at