Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the maximum thread count for QTConcurrent operations?

I'm running a QTConcurrent::Map on a list of items to perform some image processing tasks. This works well on a machine with just a few threads but runs in to problems on machines with a large number of threads due to the memory requirements of my processing code.

Is it possible to set the maximum number of concurrent threads for QTConcurrent operations or do I need to re-code with a QThreadPool where I have more control?

Thanks for any advice.

like image 934
Richard Adams Avatar asked Jul 15 '12 16:07

Richard Adams


Video Answer


1 Answers

QtConcurrent::map uses the global thread pool.

You can change its thread count with QThreadPool::globalInstance()->setMaxThreadCount(n).

like image 57
alexisdm Avatar answered Oct 11 '22 20:10

alexisdm