[Development] Question about QCoreApplicationData::*_libpaths

Marc Mutz marc.mutz at kdab.com
Sat Jan 16 19:40:36 CET 2016


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.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts



More information about the Development mailing list