[Development] Question about QCoreApplicationData::*_libpaths

Kevin Kofler kevin.kofler at chello.at
Fri Jan 22 01:31:20 CET 2016


Marc Mutz wrote:
> Ivan was talking about thread-safe classes. You need to lock a mutex to
> take the copy.

Returning a QMap instead of a std::shared_ptr<std::map> would be perfectly 
thread-safe there. The atomic reference counting would ensure that any 
thread that wants to write to the data that another thread still holds would 
detach first.

The only way to be thread-unsafe with a QMap would be to explicitly bypass 
the implicit sharing by using something like std::shared_ptr<QMap>, which of 
course doesn't make sense.

        Kevin Kofler




More information about the Development mailing list