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

K. Frank kfrank29.c at gmail.com
Fri Aug 19 21:49:57 CEST 2011


Hi Thiago!

On Fri, Aug 19, 2011 at 3:39 AM, Thiago Macieira <thiago at kde.org> wrote:
> 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:

Ah, I see.  Thanks.

> 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.

Sorry about that.  The definition I gave, in the context of the Qt
documentation,
would clearly lead to a lot of confusion.

Thanks for clearing this up.

> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org

Best.


K. Frank



More information about the Qt-interest-old mailing list