List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:August 16 2007 9:31am
Subject:Re: Eyeballs needed on new reference counted pointer template
View as plain text  
Alex Burton wrote:
> Slight improvements might be made by only testing counted_ to know if it 
> is a non null pointer instead of checking ref_ is set all the time.

This is just paranoia, of the same sort that motivates some other 
posters in this thread to recommend zeroing the pointers in detach().  I 
think they're right to be paranoid, because it justifies my own 
paranoia.  :)

You never know when some bug will cause one pointer but not the other to 
be zeroed.  If either is zero, we can't dereference the other, because 
it's not supposed to be used any more.

An earlier iteration simplified all this by wrapping both the reference 
count and the T* in a structure, and RefCountedPointer actually managed 
a pointer to a structure of this type on the heap.  It had the advantage 
of only one data member in RefCountedPointer itself, so only one thing 
to test, but it turned the single indirection of an unmanaged pointer 
into triple indirection.  Too expensive...
Thread
Eyeballs needed on new reference counted pointer templateWarren Young15 Aug
  • Re: Eyeballs needed on new reference counted pointer templateChris Frey15 Aug
    • Re: Eyeballs needed on new reference counted pointer templateWarren Young16 Aug
  • Re: Eyeballs needed on new reference counted pointer templateAlex Burton15 Aug
    • Re: Eyeballs needed on new reference counted pointer templateWarren Young16 Aug
  • Re: Eyeballs needed on new reference counted pointer templateJoseph Artsimovich15 Aug
    • Re: Eyeballs needed on new reference counted pointer templateJonathan Wakely16 Aug
      • Re: Eyeballs needed on new reference counted pointer templateWarren Young16 Aug
        • Re: Eyeballs needed on new reference counted pointer templateJonathan Wakely18 Aug
          • Re: Eyeballs needed on new reference counted pointer templateJonathan Wakely18 Aug
          • Re: Eyeballs needed on new reference counted pointer templateWarren Young20 Aug
    • Re: Eyeballs needed on new reference counted pointer templateWarren Young16 Aug
  • RE: Eyeballs needed on new reference counted pointer templateJoel Fielder15 Aug
    • Re: Eyeballs needed on new reference counted pointer templateWarren Young16 Aug
  • Re: Eyeballs needed on new reference counted pointer templateRobert Mecklenburg15 Aug
    • Re: Eyeballs needed on new reference counted pointer templateGraham Reitz15 Aug
    • Re: Eyeballs needed on new reference counted pointer templateGraham Reitz15 Aug
    • Re: Eyeballs needed on new reference counted pointer templateWarren Young16 Aug
  • Re: Eyeballs needed on new reference counted pointer templateGraham Reitz15 Aug