[Qt-interest] QHash::const_iterator not reentrant?

Thiago Macieira thiago at kde.org
Fri Aug 19 09:39:44 CEST 2011


On Thursday, 18 de August de 2011 15:12:31 K. Frank wrote:
> (A note on terminology:  I would call a function reentrant if it can call
> itself recursively, perhaps indirectly.  A thread-safe function can be
> called simultaneously by more than one thread.  Although most things that
> break reentrancy break thread safety, the two concepts are not identical.
> It is possible for a reentrant function not to be thread safe, and vice
> versa. I think you mean thread safe in the context of your post.)

Qt uses slightly different definitions on its documentation:

Reentrant is the function that can be called multiple times, from multiple 
threads or the same thread, provided that it operates on different objects.

Thread-safe is a function that can be called simultaneously from multiple 
threads, even on the same object.

QHash::iterator and const_iterator are, by that definition, reentrant. The 
QHash read-only functions (like constBegin and constEnd) are thread-safe among 
themselves: you can call them on the same object from multiple threads, 
provided you don't call a non-thread-safe function at the same time.

-- 
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: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110819/9195aa80/attachment.bin 


More information about the Qt-interest-old mailing list