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.m...@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.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 >
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development