[Qt-interest] QNetworkAccessManager & 2 threads

bd.anon at free.fr bd.anon at free.fr
Fri Oct 15 02:40:26 CEST 2010


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.




More information about the Qt-interest-old mailing list