[Interest] Write from different thread

Thiago Macieira thiago.macieira at intel.com
Thu Aug 23 12:35:36 CEST 2012


On quinta-feira, 23 de agosto de 2012 11.36.16, Marc Mutz wrote:
> On Thursday August 23 2012, Thiago Macieira wrote:
> > On quinta-feira, 23 de agosto de 2012 09.27.02, Igor Mironchik wrote:
> > > Hello.
> > > 
> > > Is it safe to write in to the QTCPSocket from the different threads if
> > > socket is protected with mutex?
> > 
> > No.
> 
> 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.

On the spot.

QMutex-protecting an object doesn't make sense. You need to block the entire 
thread from executing.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- 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://lists.qt-project.org/pipermail/interest/attachments/20120823/a9c78202/attachment.sig>


More information about the Interest mailing list