[fpc-devel] FCL Thread-safety
fpc at bcsoft.de
Wed Jan 27 08:09:29 CET 2010
Am Mittwoch, 27. Januar 2010 02:08 schrieb Nikolai Zhubr:
> Hello people,
> Is FCL thread-safe?
> To be more precise, what I mean is the following. I'm going to create
> 2 (or more) components so that they are completely unrelated to each
> other in _my_ code and use them separately within different threads
> (implemented as TThread descendants if it matters) with no
> syncronization/serialization whatsoever. Can I be sure that such
> components will not interfere each other implicitely (somewhere deep
> inside the FCL)?
No, you can't be sure. E.g. the fcl-xml stuff in latest released
fpc-2.4.0 is *not* thread-safe, because it uses avl-tree which is not
thread-safe. See http://mantis.freepascal.org/view.php?id=12984 and
note: This bug is marked as "fixed in 2.4.0" which is (partly) wrong.
The problem with xml stuff depending on avl-tree is fixed only in trunk
and in fixes_2_4 (i.e. 2.4.1).
So using e.g. xmlcfg is thread-safe only, if fpc > 2.4.0 is used.
About avl-tree: IIRC it *can* be used in a thread-safe manner, but by
default, it is not thread-safe. So any component using avl-tree might
not be thread-safe.
There might be much more stuff like this, so I recommend to verify every
components you intend to use.
> And just in case someone knows, will zeoslib components be
> thread-safe in the same sense? From a brief look, zeoslib doesn't use
> global variables too much, so I suppose zeoslib thread-safety mostly
> depends on the FCL thread-safety. (Except that zeoslib's internal
> library loader seems definitely not thread-safe, but this is no
> problem because normally it should only be used once at the very
No idea, never used zeos.
More information about the fpc-devel