Lets say I have this sample code:
{
public:
MyThead() {};
~MyThread {};
QString getTheString
() const { return m_someString;
}
protected:
void run()
{
// Do stuff with m_someString....
}
private:
}
class MyThead : public QThread
{
public:
MyThead() {};
~MyThread {};
QString getTheString() const { return m_someString; }
protected:
void run()
{
// Do stuff with m_someString....
}
private:
QString m_someString;
}
To copy to clipboard, switch view to plain text mode
If for example I call getTheString() method using other thread context will I get crash or something nasty if I do not synchronize m_someString with mutex? I had read about the reentrant and atomic reference counter in Qt but I'm still not sure if I get it right.
On my project I have created an implicitly shared class using the QSharedData technique and I have lots of members that are mixed primitive types and Qt types. The big question here is can I share copy instances of my class without the need of mutex or other type locking?
Bookmarks