Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] custom allocation/deletion
From: Brian Budge (brian.budge_at_[hidden])
Date: 2012-06-07 11:02:04


On Jun 6, 2012 9:43 PM, "Robert Ramey" <ramey_at_[hidden]> wrote:
>
> Brian Budge wrote:
> > Hi all -
> >
> > Is there a way to use custom allocation while loading from an archive?
> > I'm thinking like passing an allocator along with the archive during
> > deserialization?
>
> I'm guessing that this would not be possible without adding a new
> customization point to the library. Looks like an oversight to me.
>

Any idea how much work something like this might be?

> > Adding to this, is it possible to add a custom deleter to a shared_ptr
> > during deserialization? I am thinking of using this with boost mpi,
> > and if I send a shared_ptr over the wire with some kind of deleter,
> > the same deleter object can't be used on the other side since it's in
> > a different address space.
>
> I don't think this is true. The new object is created in the new
> address space. The object on the "new" side is not the
> same object on the "other" side.

Hmmm. Maybe the question should have been about how serialization deals
with the shared_ptr deleter. Obviously both the pointer and the deleter
will have to exist in the same address space. I suppose (if allocator
passing were allowed) that custom shared_ptr deserialization would be
required.

The case I am specifically thinking about is a pool allocator where when
the shared_ptr destructor is called, it invokes the deleter on the pointer,
returning the object to th pool. In the MPI case, a unique pool exists on
each node.

Thanks.
  Brian



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