On Friday, 2012-10-05, Olivier Goffart wrote:
> On Friday 05 October 2012 15:24:40 Tony Van Eerd wrote:
> > So that is the 'recommended' style then?
> 
> Depends what you want to do.
> If your task is CPU bounded, you can use QtConcurrent.
> If you don't need to event loop, you can reimplement the run() function.
> 
> I'd use this appreach only if your task make use of the eventloop.  For
> example if your worker receive "jobs" from signals from the main thread.
> But if you only have one process() slot that is trigerred only by the
> started signal, it is a bit overkill.
> 
> 
> This mailing list is not really for question on how to use Qt. You should
> use the interest mailing-list or the forums instead.

In principle this is true. However, recurring questions regarding that topic 
indicate that the respective documentation is either incomplete, misleading or 
wrong and documentation is part of the development effort.

For example the blog post linked to from Tony's first email and your 
recommendation above would suggest that the documentation of QThread is not 
sufficiently covering the use of "active" (event loop driven) worker objects.

However, whenever the moveToThread recommendation is advertised, especially 
with workers needing worker-thread event loop processing, I always check if 
the documentation of QTcpServer::nextPendingConnection() has changed.

Because it clearly states that QTcpSocket instances returned by that method 
cannot be used from another thread, making either that note very wrong or 
recommendation of moveToThread() very dangerous.

Cheers,
Kevin
-- 
** Qt Developer Conference: http://qtconference.kdab.com/ **

Kevin Krammer | [email protected] | Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to