[Qt-interest] Can two thread share a QAbstractSocket?

Scott Aron Bloom Scott.Bloom at onshorecs.com
Wed May 12 19:27:18 CEST 2010


If you look in the http://doc.trolltech.com/4.6/threads-reentrancy.html area of the documentation, it says classes,  functions or methods will be labeled reentrant and/or thread-safe when they are … Assume they are not.. when they are not labeled as such…

 

It goes on to say, many classes are reentrant but not threadsafe and gives the reasoning (similar to what Thiago described for QabstractSocket)

 

It has a note at the bottem that says “Note: Qt Classes are only documented as thread-safe if they are intended to be used by multiple threads”

 

In QAbstractSocket  it says “Note: All functions in this class are reentrant <http://doc.trolltech.com/4.6/threads-reentrancy.html#reentrant> .”

 

What else would you like in the docs?

 

Scott

 

 

 

From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Gabriele Kahlout
Sent: Wednesday, May 12, 2010 10:18 AM
To: Thiago Macieira
Cc: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Can two thread share a QAbstractSocket?

 

 

	
	So the notifiers always fire in the same thread. The buffers and internal state
	are not mutex-protected. If you try to use QAbstractSocket from two different
	threads (or more), you're going to have lots of data race-condition and it's
	going to either cause data loss or crash.


So Qt prevents it all together, i.e. I cannot do it and risk data loss or crash. 

It would be better if qt's documentation included such a warning, especially for thus coming from java.
 

	--

	Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
	 Senior Product Manager - Nokia, Qt Development Frameworks
	     PGP/GPG: 0x6EF45358; fingerprint:
	     E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

	
	_______________________________________________
	Qt-interest mailing list
	Qt-interest at trolltech.com
	http://lists.trolltech.com/mailman/listinfo/qt-interest




-- 
Regards, 
K. Gabriele

--- unchanged since 25/1/10 ---
P.S. Unless a notification (LON), please reply either with an answer OR with " ACK" appended to this subject within 48 hours. Otherwise, I might resend.
In(LON, this) ∨ In(48h, TimeNow) ∨ ∃x. In(x, MyInbox) ∧ IsAnswerTo(x, this) ∨ (In(subject(this), subject(x)) ∧ In(ACK, subject(x)) ∧ ¬IsAnswerTo(x,this)) ⇒ ¬IResend(this).

Also note that correspondence may be received only from specified a priori senders, or if the subject of this email ends with a code, eg. -LICHT01X, then also from senders whose reply contains it.
∀x. In(x, MyInbox) ⇒ In(senderAddress(x), MySafeSenderList) ∨ (∃y. In(y, subject(this) ) ∧ In(y,x) ∧ isCodeLike(y, -LICHT01X) ).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100512/94201ab8/attachment.html 


More information about the Qt-interest-old mailing list