[fpc-devel] Suggestion: reference counted objects

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sun Sep 21 05:34:26 CEST 2014


Sven Barth schrieb:
> Am 20.09.2014 20:34 schrieb "Giuliano Colla" 

>  > 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.
> 
> That would work the same way as it does in interfaces, arrays and 
> strings: using Interlocked*-functions.

As I understand Interlocked Inc/Dec funtionality, it only protects the 
update of the reference counter against interrupts, but not the tests 
required before/after this update. As a precaution a RefCount should at 
least be incremented as soon as there exists a *chance*, that the 
reference is used/copied in some piece of currently active code (thread...).

DoDi




More information about the fpc-devel mailing list