Could point at some code using QRunnable as an alternative to QtConcurrent: I can't find any QRunnable example in Qtdoc.
Did you ever try QRunnable AND QtConcurrent for same application, and could you comment on the compared performance?
QRunnable
is an interface. So rather than looking for "a QRunnable
example" it would be better to look for (for instance) "a QThreadPool
example", such as:
http://doc.qt.io/qt-4.8/thread-basics.html#example-1-using-the-thread-pool
If you read further on that page, it mentions the real value in QtConcurrent is when you are doing something similar to applying an STL algorithm to an STL container. Using a thread pool with QRunnable is better for when you just have a bunch of fairly unrelated tasks to perform.
QtConcurrent is built on top of QThreadPool. It's notationally convenient and keeps you from having to write the patterns yourself, but is not going to intrinsically speed you up over what you could hand code. But...thinking in terms of QtConcurrent patterns (such as MapReduce) may help you see opportunities for parallelism you wouldn't otherwise think of, and writing less code means it's easier to try alternative approaches and compare their performance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With