PDA

View Full Version : Reads from multiple threads on a single instance of a QMap



KenW
13th April 2011, 21:24
Is it safe to do reads on a single instance of a QMap from multiple threads? I realize that writes would be totally unsafe.

I could make copies of the QMap and pass them into the threads because they are implicitly shared and the copy would be fast, but I wonder if that is necessary. In other words are there private variables in a QMap that might be corrupted if there were simultaneous lookups from multiple threads?

I know that an implicit copy copies the QMap object itself, but not the key/value data pointer. Therefore I think I need to send each thread its own implicit copy to be safe.

Thanks for the advice.

mcosta
14th April 2011, 00:08
As general rule, multiple concurrent readings should not be a problem.