Re: KStringHandler: stateless/reentrant/thread-safe?

Thomas Lübking thomas.luebking at gmail.com
Fri Oct 26 21:00:08 BST 2012


On Freitag, 26. Oktober 2012 21:06:35 CEST, Frank Reininghaus wrote:

> Yes, I thought the same, but then I wasn't entirely sure if all these
> functions really are thread-safe. Some of them have const static variables,
> which might be initialised the first time the function is called AFAIK. I
> don't know if that's guaranteed to work if the functions can be called from
> multiple threads. 

The great oracle of mountain view says: "depends".

First 3 results:
----------------
http://stackoverflow.com/questions/1962880/is-c-static-member-variable-initialization-thread-safe

http://eli.thegreenplace.net/2011/08/30/construction-of-function-static-variables-in-c-is-not-thread-safe/

http://blogs.msdn.com/b/oldnewthing/archive/2004/03/08/85901.aspx



Reads to me:
run functions with local statics once before starting threads (or move them to a global scope if reasonable)

Cheers,
Thomas




More information about the kde-core-devel mailing list