[fpc-devel] Suggestion: reference counted objects

Chriss Kalogeropoulos iz.iznogood at gmail.com
Sat Sep 20 21:07:01 CEST 2014


You don't miss anything, we agree. That is why I propose an explicit
implementation either using a compiler switch or generic records (smart
pointer). This way the developer has full control on when the feature is
used or not. The smart pointer approach is more flexible I believe.

Sorry for the noise,
Chriss
Στις 20 Σεπ 2014 9:34 μ.μ., ο χρήστης "Giuliano Colla" <
giuliano.colla at fastwebnet.it> έγραψε:

>
> Il 20/09/2014 19:20, Boian Mitov ha scritto:
>
>    Hi Chriss,
>
> Personally I favor reference counted objects. While there are interfaces
> as you pointed, and in Delphi you can even use smart pointers now, there is
> still a lot of cases when you need to use objects, and have to manually
> free them.
> In single threaded environment that is not such an issue, but in parallel
> and heavily multithreaded environments, reference counting is a life saver.
>
>
> Can you explain how reference counting can be safely implemented in a
> parallel multithreaded environment, without heavily affecting performance?
> A mere increment or decrement of count means to get a lock and to release
> a lock on that object. Application code can know what is thread safe and
> what is not, and use lock only when appropriate.
> A general mechanism to be reliable should take into account all
> possibilities. If it does, it will block threads even when unnecessary. If
> it doesn't, it will be unsafe.
>
> What do I miss?
>
> Giuliano
>
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140920/2a0e9309/attachment.html>


More information about the fpc-devel mailing list