Re: QtConcurrent question
Ok, now I see it was a stupid C++ question, sorry. Solved the problem by making cycle and member variables it uses static. Now everything seems to work, I've got 4x speedup.
Re: QtConcurrent question
Things turn out to be not so easy. Yes, I've got 4x speedup, but cycle() function generates huge amount of data (hundreds of megabytes) which should be written to a file, but my attempts to write output data from that function have no success. In my MainWindow class I have static QDataStream member out, and I'm using it for output. During execution there is a lot of qDebug messages "QIODevice::write: ReadOnly device", and output file remains absolutely empty, though if I write something to out before QtConcurrent::map() is started, it is written to a file without problems.
As far as I understand, multiple threads generated by QtConcurrent::map() somehow automatically lock out and prevent each other from writing to it. Or may be I am wrong? Anyway, what could be done to avoid this?
Please give me a hint, I'm stuck and this thing is starting to drive me crazy...
Re: QtConcurrent question
Any suggestion would be appreciated. Even something like "RTFM".
Re: QtConcurrent question
You can't access a QIODevice from multiple threads at once, that's for sure. Try returning the data from calculations to the main thread and then writing it sequentially from there.
Re: QtConcurrent question
Thank you very much. I was thinking about returning data from the calculations to the main thread, but the problem is that there's too much data to handle, so I was afraid that memory consumption will be unacceptably high. Now I think I'll manage it.
Thanks again, you saved me from many hours of attempts to walk through a brick wall.