About setMaxThreadCount limit



  • 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?



  • 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.


  • Qt Champions 2016

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.