|
Boost Users : |
Subject: Re: [Boost-users] Fw: Use of QMutex not as expected
From: Lorenzo Trivelli (trivelli.lorenzo_at_[hidden])
Date: 2015-08-26 04:02:48
Il 25/08/2015 13:31, Don El Ron ha scritto:
It seems that each myResource instannstance has its own mutex, so
if you pass it by copy in the MyWorkerXX constructors each of the
MyWorkerXX instance will lock on a different mutex.
This can be avoided in many ways, it depends on what kind of locking
is required:
1) if each MyResource still needs a separate mutex, then you should pass
it to MyWorkerXX class by reference, so each worker thread will lock
on the same mutex
2) if all of MyResouce instances must be synchronized on the same mutex,
then you can make the mutex object static and pass MyResouce to MyWorkerXX
as you like, as the mutex will always be the same
regards
Lorenzo
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net