You can't use a non-static member function from another class. It either has to be static or can't be a member function. What is allowed and what is not is described in Qt Concurrent docs.
You can't use a non-static member function from another class. It either has to be static or can't be a member function. What is allowed and what is not is described in Qt Concurrent docs.
Got it...
Took me a while to get that EVERYTHING the QtConcurrent thread uses has to be static.
Just having a bit of trouble with QFutureWatcher and QtConcurrent. Sometime the app crashes after about 20 files, other times it runs fine, but 'locks' the computer as all 8 cores are running at 100%...
You can use
to limit the number of threads.Qt Code:
QThreadPool::globalInstance->setMaxThreadCount()To copy to clipboard, switch view to plain text mode
And if your application still is crashing, you are probably still accessing a shared variable in an unsafe way. I'm thinking of myList and allFiles.
It sounds like QtConcurrent::mappedReduced could be a candidate for you.
What exactly does your thread method do? Is there a chance you could post the code here?
Because as is writen in documentation Programs written with QtConcurrent automatically adjust the number of threads used according to the number of processor cores available. So they consume 100% available cores.
Your first idea with ThreadManager and WorkerThread is good. You must only create slot in ThreadManager and connect to them signal QThread::finished(). In this slot start worker with next file.
Bookmarks