On Saturday 16 January 2016 15:44:47 Иван Комиссаров wrote: > However, in multithreaded app this won't work! Imagine, Manager will try to > modify map while someone holds pointer to it. First, pointer should be > protected with mutex both in getter and the place when manager modifies the > map. Second, the map should be copied before modification. > The alternative is to always copy map on each get() operation.
You can lock a mutex in the function and unlock it in the shared_ptr's deleter. Of course, that means that no-one should hold on to those references for long, but they can always copy the map. -- Marc Mutz <marc.m...@kdab.com> | Senior Software Engineer KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company Tel: +49-30-521325470 KDAB - The Qt Experts _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development