[haiku-development] Re: BReferenceable bug?

  • From: Joseph Groover <looncraz@xxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 04 Apr 2012 01:13:10 -0500


you can overwrite LastReferenceReleased and not "delete this;". Then it makes sense to call the FirstReferenceAcquired, i.e. when fReferenceCount gets > 0 again. Think its better to not call FirstReferenceAcquired in the constructor though. This may mess up classes which uses the FirstReferenceAcquired in this way. To sum up, BReferenceable seems fine to me.

Regards,
    Clemens




Okay, so the intended usage is that the owner owns an automatic reference which it must manually release when it is acceptable for the object to be destructed (or possibly recycled).

Then, FirstReferenceAcquired() would only be called in the event the object does not self-destruct when it has zero refs, but instead dangles in an accessible manner awaiting a moment for destruction.

This is quite acceptable for my uses as I intend for WindowBuffers to survive their Windows until memory needs to be freed or the allocated memory can be re-used - while also guaranteeing the memory will be accessible so long as it is needed (e.g. for fading effects after the window has officially already been destroyed).

I just expected to see a FirstReferenceAcquired() call when I created the first ref, and LastReferenceReleased() called when I released it. I merely add one line of code to make up the adjustment ;-)

Thanks Clemens, Alex!

--The loon

Other related posts: