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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
QRunnableis an interface. So rather than looking for “aQRunnableexample” it would be better to look for (for instance) “aQThreadPoolexample”, 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.