How can I manage quantity threads making by QThreadPool?
-
-
I have i3-4130 processor and due to hyper- threading IdealThreadCount in my case is 4. I tried use:
setMaxThreadCount(2); or Tasks.reserveThread(); Tasks.reserveThread();
but it doesn't work: program use all 4 threads.
How can I set only 2 thread?Hi @AlekseyB,
How can I set only 2 thread?
According to documentation it should work with setMaxThreadCount(2)
Which version of Qt are you using? And which platform?
-
I have i3-4130 processor and due to hyper- threading IdealThreadCount in my case is 4. I tried use:
setMaxThreadCount(2); or Tasks.reserveThread(); Tasks.reserveThread();
but it doesn't work: program use all 4 threads.
How can I set only 2 thread?@AlekseyB said in How can I manage quantity threads making by QThreadPool?:
setMaxThreadCount(2);
Can you show how you call it?
-
Hi @AlekseyB,
How can I set only 2 thread?
According to documentation it should work with setMaxThreadCount(2)
Which version of Qt are you using? And which platform?
Which version of Qt are you using? And which platform?
x64-5.10.0Can you show how you call it?
class TaskManager: public QThreadPool { QThreadPool* ThreadPool; public: TaskManager() {ThreadPool = QThreadPool::globalInstance();} void addTask(QRunnable* const Task_, cint Priority_ = 0) {ThreadPool->start(Task_, Priority_);} void WaitForFinish() {while(!ThreadPool->waitForDone(500)) QApplication::processEvents();} }; ... TaskManager Tasks; Tasks->setMaxThreadCount(2); //or Tasks.reserveThread(); Tasks.reserveThread();
-
Hi,
You are creating a new QThreadPool in which you get the global instance. Then you modify your custom thread pool but still use the unmodified global instance to start your work.
-
Hi,
You are creating a new QThreadPool in which you get the global instance. Then you modify your custom thread pool but still use the unmodified global instance to start your work.