EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: About the reference counting in GDD smart pointer
From: [email protected]
To: Jeff Hill <[email protected]>
Cc: [email protected]
Date: Fri, 28 Aug 2009 16:55:26 +0800

Hey Jeff,

I think the GDD smart pointer is a little bit weird, in a common way to use smart pointers as follows:

{
    smartGDDPointer sGDDPtr=new gdd();
}

the newly allocated gdd object isn't freed when sGDDPtr is out of scope. If you want to use smartGDDPointer as a normal smart pointer, you must place a line code immediately below the new operator, like this:

{
    smartGDDPointer sGDDPtr=new gdd();
    //The reference count of the newly created gdd object is actually 2 at this time.
    //The gdd() places the reference count to 1, and the assignment operator increase it to 2.
    sGDDPtr->unreference();
}

We see that smartGDDPointer is the intrusive type of smart pointer, the gdd has one reference count member and two functions reference() and unreference(). In my opinion, the init() called by the gdd constructors shouldn't place the reference count to 1, the reference counting shouldn't be carried out by gdd itself. smartGDDPointer is the manager of the gdd object and the only guy who can operate the reference() and unreference() on gdd object

Thanks,

Alex

Replies:
RE: About the reference counting in GDD smart pointer Jeff Hill

Navigate by Date:
Prev: Re: proper thread cleanup on Linux? Ernest L. Williams Jr.
Next: RE: About the reference counting in GDD smart pointer Jeff Hill
Index: 2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: proper thread cleanup on Linux? Ernest L. Williams Jr.
Next: RE: About the reference counting in GDD smart pointer Jeff Hill
Index: 2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Feb 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·