Multiple instance of QNetworkAccessManager from multiple threads.
-
Hi,
How safe it is to use multiple instance if QNetworkAccessManager from multiple threads ? I have a requirement to use multiple instance of QNAM from multiple threads in a mobile application (Android & iOS) for rest API calls (both http & https). I see it is recommended to use one instance per application (https://doc.qt.io/qt-5/qnetworkaccessmanager.html](https://doc.qt.io/qt-5/qnetworkaccessmanager.html) , but any harm if this is not followed ?
I am on Qt 5.15.1.Thanks,
Manasa -
The note in the documentation,
Note: All functions in this class are reentrant, means that using multiple instances from different threads is safe. Each instance should only be used from its associated thread.https://doc.qt.io/qt-5/threads-reentrancy.html
As to the harm or utility of having multiple instances, it might be a waste of memory and network bandwidth, or it might be useful to have access managers configured for different caches, proxies, etc. At least one of the Qt Location plugins uses its own QNAM to manage a map tile cache.