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. About setMaxThreadCount limit

About setMaxThreadCount limit

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 3 Posters 857 Views
  • 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.
  • ArronA Offline
    ArronA Offline
    Arron
    wrote on last edited by
    #1

    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
    0
    • Paul ColbyP Offline
      Paul ColbyP Offline
      Paul Colby
      wrote on last edited by
      #2

      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
      3
      • kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #3

        @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
        2

        • Login

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