Hi, 
Thanks for your detailed explanations.
I was paying with your nice example.
Currently my structure is keeping only several floats, ints and unsigned ints. Following the Interprocess documentation, as you  wrote, I can put them directly into shared memory:

 server_side:
   P.insert(particleID(0,0));
   P.insert(particleID(-1,1));
   P.insert(particleID(-2,2));
   P.insert(particleID(-3,3));
   try{
      //Erase previous shared memory
      shared_memory_object::remove("shared_memory");

      //Create a shared memory object.
      shared_memory_object shm (create_only, "shared_memory", read_write);

      //Set size
 size_t P_len=P.size()*sizeof(particleID);
      shm.truncate(P_len);

      //Map the whole shared memory in this process
      mapped_region region(shm, read_write);

      //Write all the memory to 1
      std::memset(region.get_address(), 1, region.get_size());
 print_out_by<ID>(P);
 boost::xtime xt;
 boost::xtime_get(&xt, boost::TIME_UTC);
 xt.sec += 100;
 for(;;)boost::thread::sleep(xt);  
   }
   catch(interprocess_exception &ex){
      shared_memory_object::remove("shared_memory");
      std::cout << ex.what() << std::endl;
      return 1;
   }

Now I am trying to access the memory from client:
  shared_memory_object shm (open_only, "shared_memory", read_only);

      //Map the whole shared memory in this process
      mapped_region region(shm, read_only);

      //Check that memory was initialized to 1
      const particlesID_set *P = static_cast<particlesID_set*>(region.get_address());
 
 //const particlesID_set::nth_index<1>::type L1_ID_index = (*P).get<1>();// This does not compile, Why?

 print_out_by<ID>((*P));  //This cannot access the memory...

In Client I cannot get the index, it claims that cannot access to protected member.

Maybe I am missing something?Could you please advice me?

kind regards Arman.
On Tue, Apr 6, 2010 at 8:59 PM, Joaquin M Lopez Munoz <joaquin@tid.es> wrote:
arm2arm <arm2arm <at> gmail.com> writes:
>
>
> Hello,
> I would like to load multiindex container by one process lets say
> serverside_loader. And access that array by another clientside_analyser
> process? How to do that?

Hi Arman,

Yes, this can be done. There's an example that shows you how
to do it:

http://www.boost.org/libs/multi_index/doc/examples.html#example12

Basically, you've got to take care of three things:

* The element type (particleID in this case) must be placeable
in shared memory, see

http://tinyurl.com/ygau74j

for info on the limitations imposed on such objects. particleID
is a simple class and can be directly put in shared memory.
* You must use a special Boost.Interprocess allocator for
the multi-index container. Use the aforementioned example as
a guide.
* Access to the container must be properly synchronized, just
as you'd do for instance in a multi-threaded program.

Good luck with your project, come back if you have some
difficulty.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users