Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved About setMaxThreadCount limit

    Mobile and Embedded
    3
    3
    583
    Loading More Posts
    • 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.
    • Arron
      Arron last edited by

      I want to create a socket UI.
      In these code:
      MyClient::MyClient(QObject *parent) :
      QObject(parent)
      {

      QThreadPool::globalInstance()->setMaxThreadCount(5);
      

      }

      I found setMaxThreadCount restrict the client sent information to server.
      Does it have any way to be unlimited number in the brackets?

      1 Reply Last reply Reply Quote 0
      • Paul Colby
        Paul Colby last edited by

        Hi @Arron,

        Does it have any way to be unlimited number in the brackets?

        There's no direct way to make it unlimited... Of course the number of threads will always be limited by the host OS, but you could I suppose (not sure why) ensure that Qt is not posing any arbitrary limit by using MAX_INT; like:

        QThreadPool::globalInstance()->setMaxThreadCount(MAX_INT);
        

        @Arron said:

        I found setMaxThreadCount restrict the client sent information to server.

        How did you find that? In what way is it restricting the information? You might want to revise your application's structure rather than (or at least in addition to) using more threads.

        Cheers.

        1 Reply Last reply Reply Quote 3
        • kshegunov
          kshegunov Moderators last edited by

          @Arron
          To add to @Paul-Colby's excellent points, setting anything above QThread::idealThreadCount() is useless. There's something that's called a scheduler in the OS which does the thread context switching, and you'll gain no speed(!) by using more threads than the number of cores.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply Reply Quote 2
          • First post
            Last post