[fpc-devel] ref count types / threadsave question

Jonas Maebe jonas at freepascal.org
Wed Jan 2 20:14:59 CET 2019

On 02/01/19 20:08, Martin wrote:
> If a local string var has a refcount of 1, then it can not be accessed 
> by any other thread. Therefore it needs no lock for decreasing the ref.

You would need a full memory barrier before checking whether the 
reference count is one, otherwise it could have been increased to two by 
another thread on another core quite a while ago without that change 
being already visible on the current core. This would probably slow down 
things much more than any potential gain from not performing the atomic 


More information about the fpc-devel mailing list