[Development] Question about QCoreApplicationData::*_libpaths

Иван Комиссаров abbapoh at gmail.com
Fri Jan 22 09:57:00 CET 2016


But i don't have multiple writers (1 thread can change map, multiple can
read) and QMap actually uses atomics (so no memory ordering problems). What
i'm missing?

2016-01-22 13:00 GMT+03:00 Marc Mutz <marc.mutz at kdab.com>:

> On Friday 22 January 2016 09:43:17 Иван Комиссаров wrote:
> > Why? In case of QMap, we have no need to use operator= to change the map.
> > We simply detach and insert new data in it.
> > Of course, in case of multiple changes, the map can reach some "invalid
> > state" before changes are finished (i.e. in case we need transacted
> > changes, we have to use mutex anyway). But it is not neccessary in some
> > cases.
>
>    class IWantToBeThreadSafe {
>        int m_i;
>    public:
>        void setI(int i) { m_i = i; }
>        int i() const { m_i; }
>    };
>
> Make this class thead-safe (without QAtomicInt :).
>
> Then replace 'int' with QMap.
>
> Then you have your answer.
>
> --
> 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
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20160122/4299bf1e/attachment.html>


More information about the Development mailing list