Boost logo

Boost :

Subject: Re: [boost] [block_ptr] Request for a review manager
From: Phil Bouchard (philippeb8_at_[hidden])
Date: 2016-02-09 18:32:02


On 02/09/2016 12:08 PM, Peter Dimov wrote:
>> Phil Bouchard wrote:
>>
>> > I added the new repository with the right folder structure:
>> > https://github.com/philippeb8/block_ptr
>
> Here's one vector example that shows what I had in mind:
>
> #include <boost/block_ptr.hpp>
> #include <vector>
> #include <iostream>
>
> struct X
> {
> static int instances;
>
> std::vector< boost::block_ptr<X> > v_;
>
> X()
> {
> ++instances;
> std::cout << "X(" << this << ")::X()\n";
>
> v_.reserve( 4 );
> }
>
> ~X()
> {
> std::cout << "X(" << this << ")::~X()\n";
> --instances;
> }
> };
>
> int X::instances = 0;
>
> int main()
> {
> boost::block_ptr<X> p = boost::make_block<X>();
>
> p->v_.push_back( p );
>
> std::cout << "--\n";
>
> p.reset();
>
> std::cout << "--\n";
> }
>
> It doesn't seem to release the cycle.

Like I was saying in a PM, containers should use block_allocator<>:
https://github.com/philippeb8/block_ptr/blob/master/example/block_ptr_test3.cpp#L76

It works well but Peter discovered a deadlock in reset() so perhaps it's
a simple fix.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk