[fpc-devel] Suggestion: reference counted objects

Sven Barth pascaldragon at googlemail.com
Sun Sep 21 12:41:36 CEST 2014

On 21.09.2014 05:34, Hans-Peter Diettrich wrote:
> 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...).

No, why should it? It works pretty well with interfaces, strings and 
arrays (let's put aside modifying the latter two, because COW is not 
needed here).


More information about the fpc-devel mailing list