[fpc-devel] Suggestion: reference counted objects

Constantine Yannakopoulos alfasud.ti at gmail.com
Sun Sep 28 21:00:13 CEST 2014


​Hi Sven,​

On Sat, Sep 27, 2014 at 7:33 PM, Sven Barth <pascaldragon at googlemail.com>
wrote:

> Huh? Delphi really prohibits such things inside the destructor? Would you
> mind to share an example (possibly including error messages), please?
>

​Sorry, I wasn't clear enough. ​
​With ​"prohibits" I didn't mean that you get a compiler error. It compiles
and runs just fine but you get a stack overflow at runtime
​ when the dest​
​ructor is called​
.

I've done a different approach already: the decrease helper sets refcount
> to -1 directly before it calls the destructor and both the increase and the
> decrease helper check for -1. Considering that it's currently only a proof
> of concept I can live with the performance impact that comparison might
> have.


​OK, but keep my proposal in mind since it has overhead only at
BeforeDestruction which is once per instance lifecycle.

--Constantine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140928/620ac4fc/attachment.html>


More information about the fpc-devel mailing list