How to use QMutex to lock on other thread when passing by pointer?
General and Desktop
5
Posts
2
Posters
1.6k
Views
1
Watching
-
@
class MyData
{
public:
void setNumber(int newValue)
{
QMutexLocker locker(&mutex);
number = newValue;
}protected:
int number;
QMutex mutex;
};
@Done :-)
Althoug I wouild recommend using Qt::QueuedConnection and signals and slots, if possible. This way you avoid locking altogether.
-
Not a requirement, just my preference.