KStringHandler: stateless/reentrant/thread-safe?

Thiago Macieira thiago at kde.org
Sat Oct 27 17:29:23 BST 2012


On sexta-feira, 26 de outubro de 2012 22.44.23, Thiago Macieira wrote:
> On sexta-feira, 26 de outubro de 2012 21.06.35, 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. But you can probably answer that question
> 
> Caching some global information which could be recreated on every call is
> stateless and thread-safe.

Actually, this is wrong. Caching is a good thing, but it could cause a thread-
safety issue if not implemented correctly.

The presence of statics probably requires a good investigation to check if 
it's thread-safe. And removing the "stateless" requirement is still a good 
idea.

> 
> If the static variable cannot be recreated on every call, it's stateful.
> That contradicts the documentation.
-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20121027/3221e116/attachment.sig>


More information about the kde-core-devel mailing list