Locking of semi-read-only QVector
Good day, colleagues!
Suppose I have 2 threads and QVector<double> with fixed size, initialized as QVector<double> (fixed_size). First thread consequently fills this QVector with data. Second thread only reads this QVector and it’s guaranteed that second thread reads only elements, which are already processed by the first thread. For example, if second thread reads vector.at(0), it’s guaranteed that vector.at(0) is filled by the first thread and will not change anymore.
The question is shoud I lock QVector with QMutex or not?
4 replies
No problem. Sounds like you could be a potential user of this class [qt.gitorious.org] that I wrote. I have a small wrapper around this class that makes it into a thread-safe container for the producer-consumer pattern.
You must log in to post a reply. Not a member yet? Register here!



