[fpc-devel] Rather large flaw in TJSONConfig component

Michael Van Canneyt michael at freepascal.org
Tue Jun 22 11:44:10 CEST 2010



On Tue, 22 Jun 2010, Graeme Geldenhuys wrote:

> Op 2010-06-22 11:17, Henry Vermaak het geskryf:
>>>
>>> My point is that this is the wrong place to build such functionality
>>> in.  How do you propose this should work from different files or
>>> processes?
>>
>> s/files/threads
>
> In tiOPF we have a Singleton for INI file processing. It uses the
> TMultiReadExclusiveWriteSynchronizer class no manage access, and it is
> thread-safe.
>
> FPC finally has a working TMultiReadExclusiveWriteSynchronizer
> implementation (tiOPF implemented it's own), but I don't know if that
> implementation is available for FPC 2.4.x yet, or if it is still only in
> Trunk.  Either way, TXXXConfig classes could use the same synchronizer to
> manage access - with a bit of refactoring.

Nono.

We'll put a big warning 'Not concurrency safe' in the files.

Keep it simple. It works for 99% of all use cases. The 1% that need concurrency
can use another solution. We should provide this solution, but not in the
standard classes.

TStringlist is also not thread safe, and that is OK as long as you know it.
Making it thread safe is possible, but would slow it down in most of the
cases where it is simply not needed.

Michael.



More information about the fpc-devel mailing list