C++ (Qt)shared_ptr<Data> ptr;DataManager dataManager;...ptr = dataManager.data();
C++ (Qt)shared_ptr<Data> ptr;DataManager dataManager;...for (int i = 0; i < 100 ++i) { ptr = dataManager.data(); ...}
class Data {}class DataManager{public: ... // Раньше было data() SharedPointer<Data> getDataSnapshot() const { ReadLocker lock; return m_data; } ...}
... const SharedPointer<Data> getDataSnapshot() { ReadLocker lock; return m_data; } const SharedPointer<const Data> getDataSnapshot() const { return const_cast<DataManager*>(this)->getDataSnapshort(); }...
C++ (Qt) const SharedPointer<const Data> getDataSnapshot () const { ReadLocker lock; return m_data; }
... SharedPointer<const Data> getDataSnapshot() const { ReadLocker lock(m_mutex); return m_data; }private: mutable Mutex m_mutex;