[fpc-devel] FCL Thread-safety

Leonardo M. Ramé martinrame at yahoo.com
Wed Jan 27 13:30:46 CET 2010


I can confirm FCL-XML is thread safe, at least in FPC 2.5.1, also Zeos as far as you create a new connection to the database inside each thread.

I'm using both libraries in a multithreaded daemon that receives an XML file via socket, then connects to a Postgres database using Zeos. 

While developing this, the first issue was many database deadlocks, and transaction problems caused because I was sharing a global database connection, the solution was creating an instance of the database connector in the Thread constructor, and destroy it in the Thread destructror. Regarding the FCL-XML, I was using an old version based on AVLTree, and found it have many problems when working within threads, all of them solved after upgrading to the latest version.


Leonardo M. Ramé
http://leonardorame.blogspot.com

--- On Tue, 1/26/10, Nikolai Zhubr <zhubr at mail.ru> wrote:

> From: Nikolai Zhubr <zhubr at mail.ru>
> Subject: [fpc-devel] FCL Thread-safety
> To: fpc-devel at lists.freepascal.org
> Date: Tuesday, January 26, 2010, 11:08 PM
> 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)?
> 
> 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 beginning)
> 
> Thank you!
> 
> Nikolai
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
> 


      



More information about the fpc-devel mailing list