Boost logo

Boost Users :

From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2008-05-30 15:22:45


Jan Suchý wrote:

> Now, I want to have library, where i want to find previously created shared segment and read it more-times.
> But I do not want to open it on every runQ function call.
> I need to open this segment only once and use it more-times when runQ in lib is called.
>
> I tried this:

The problem is that managed_shared_memory is not copyable. With current
trunk code you could move it from localsegment to segment:

          managed_shared_memory localsegment(open_only, "MySharedMemory");
          segment = move(localsegment);
         //localsegment is now in default-constructed state

For 1.35 code allocate it through new (not compiled, this might contain
errors):

std::auto_ptr<managed_shared_memory> segment_ptr;

int init()
{
    segment_ptr.reset
       (new managed_shared_memory
          (open_only, "MySharedMemory")
       );
}

Regards,

Ion


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