Boost logo

Boost Users :

Subject: Re: [Boost-users] [Interprocess] shared_ptr in a non-throwing mode
From: Pietro Versari (pietro.versari_at_[hidden])
Date: 2011-04-07 07:03:13


2011/4/6 Ion Gaztañaga <igaztanaga_at_[hidden]>
>
> El 06/04/2011 13:19, Pietro Versari escribió:
>>
>> Hi Ion (and everyone else),
>>
>> I'm a newbye and I have only one simple question:
>> how can I construct a shared_ptr in a non-throwing mode?
>>
>> This example throw if there is enough space for MyType but isn't
>> enough for my_shared_ptr:
>>
>> typedef managed_shared_ptr<MyType,managed_shared_memory>::type
>> my_shared_ptr;
>> my_shared_ptr sh_ptr = make_managed_shared_ptr(
>>     segment.construct<MyType>("object to share", std::nothrow)(), segment);
>
> Then it's a bug ;-) Boost version please?

1.45.0, 1.46.0, 1.46.1 (gcc 4.4.3 and icc 12.0.2; OS: Ubuntu 10.04).

But I have one question: these pieces of code are equivalent?

typedef managed_shared_ptr<MyType,managed_shared_memory>::type my_shared_ptr;
// piece 1
my_shared_ptr sh_ptr = make_managed_shared_ptr(
    segment.construct<MyType>("object to share", std::nothrow)(),
    segment);
// piece 2
MyType * instance = segment.construct<MyType>("object to share",
std::nothrow)();
my_shared_ptr sh_ptr = make_managed_shared_ptr(
    instance,
    segment);

When I create an object of MyType in shared memory the Managed Memory
Segments allocate portions of that segment in non-throwing mode, and
when I create a shared_ptr the Managed Memory Segments allocate
portions of that segment.
How can the Managed Memory Segments understand that must allocate the
portions of that segment for the shared_ptr in non-throwing mode?

Thanks,
Pietro Versari


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