Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Multiple instance of QNetworkAccessManager from multiple threads.
Qt 6.11 is out! See what's new in the release blog

Multiple instance of QNetworkAccessManager from multiple threads.

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 2 Posters 515 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Manasa
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by
      #2

      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.

      Asking a question about code? http://eel.is/iso-c++/testcase/

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved