[Qt-interest] QNetworkAccessManager & 2 threads

Scott Aron Bloom Scott.Bloom at onshorecs.com
Fri Oct 15 03:00:39 CEST 2010


I have gone with #2... Having a QNAM in each thread, and using the
objects created from QNAM of each thread completely separate...

Another option...

Have the QNAM completely in the GUI, and when the data comes through
send it to the thread for processing.

Scott

-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of bd.anon at free.fr
Sent: Thursday, October 14, 2010 5:40 PM
To: qt-interest at trolltech.com
Subject: [Qt-interest] QNetworkAccessManager & 2 threads

I have a need for processing some large near real time data set
imported into the app through QNetworkAccessManager.

To keep the user interface smooth, I would like to have 2 threads,
located on 2 processors : 
- one for the large data set import and subsequent heavy processing ;
- and a second one for the UI, with some occasional web app access,
and infrequent but processor intensive graphics that must not slow
down the near real time data processing.

Hence the need to access QNetworkAccessManager from 2 threads.

Unfortunately, documentation says QNetworkAccessManager is reentrant,
but not multithreaded.

Should I understand :
1) That it is ok to have only one QNetworkAccessManager called from 2
threads, provided I make sure that all data passed as a parameter to
QNetworkAccessManager is thread specific ? 

If that is the recommended option, is it ok to locate
QNetworkAccessManager in the non UI thread ? I have a very large
number of small to medium size packets to process in the non UI
thread, and would rather try to avoid the subsequent large number of
unnecessary interthread slot/signal processing a UI thread-based
QNetworkAccessManager would imply.

2) That it is also ok if I have a specific QNetworkAccessManager in
each thread, each with it's own event loop and local data ?

Or 
3) would you recommend to create a second process as a replacement for
the non UI-based thread ?

Thanks for any clarification.

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




More information about the Qt-interest-old mailing list