Boost logo

Boost Users :

From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2005-05-15 09:25:49


> Date: Sun, 15 May 2005 12:00:55 +0100
> From: Jean-Fran?ois Brouillet <verec_at_[hidden]>
> Subject: [Boost-users] Re: shared_ptr, intrusive_ptr ...
> To: boost-users_at_[hidden]
> Message-ID: <A42134A2-8F76-4A80-956A-D0070056100F_at_[hidden]>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> On 2005-05-15 00:49:54 +0100, "Peter Dimov" <pdimov_at_[hidden]> said:
>
>
> Anyway, here's my revised snippet that satisfies all my criteria:
> --
> JFB
>
> #include <iostream>
>
> #include <boost/intrusive_ptr.hpp>
>
> struct ObjectStruct {
> int refCount ;
>
> ObjectStruct() : refCount(0) {
> std::cout << std::hex << (int) this << " - I'm born" <<
> std::endl ;
> }
>
> void refer() { ++refCount ; }
> void unrefer() { if (--refCount == 0) delete this ; }
>
> virtual ~ObjectStruct() {
> std::cout << std::hex << (int) this << " - I'm gone" <<
> std::endl ;
> }
> } ;
>
> void intrusive_ptr_add_ref(ObjectStruct * p) { p->refer() ; }
> void intrusive_ptr_release(ObjectStruct * p) { p->unrefer() ; }
>

Are you going to make it thread-safe (or is that something you just
left out of the example?)?


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