[Interest] Write from different thread

Giuseppe D'Angelo dangelog at gmail.com
Thu Aug 23 13:00:43 CEST 2012


On 23 August 2012 10:36, Marc Mutz <marc.mutz at kdab.com> wrote:
>
> To expand on this:
>
> QTcpSocket is-a QIODevice which is-a QObject, and no QObject can be protected
> by a mutex, since it performs implicit event handling which would be very
> complex to mutex-protect.

A documentation thought: shouldn't we add another category to the
thread-safety capabilities of a class or a function?

Now we have:
1) non-reentrant: safe to be used by only one thread
2) reentrant: safe to be used by multiple threads, provided that
access is serialized ("one at a time")
3) thread-safe: safe to be used by multiple threads, even at the same time

But probably 1 and 2 should be split into something like
1a) safe to be used by a *specific* thread only (GUI classes => only
in the GUI thread)
1b) safe to be used by only one thread (QObjects => use them from the
thread they live in.*)
2) reentrant: as above

-- 
Giuseppe D'Angelo

* Yes, of course, if you manage to control event dispatching then 1b
collapses onto 2, but that's not really how QObjects are meant to be
used, is it?



More information about the Interest mailing list