View Single Post
Old 08-15-2015, 08:43 AM   #11
mviljamaa
Human being with feelings
 
Join Date: Jun 2015
Posts: 348
Default

Quote:
Originally Posted by Xenakios View Post
It matters a lot, IMutexLock's constructor only accepts an IPlugBase pointer (and by extension pointers to subclasses of IPlugBase). So passing something else into the constructor of IMutexLock would be a compile error.

Remember, IMutexLock itself isn't a mutex, it only uses the internal mutex object of IPlugBase. The "this" passed into the constructor is just for the purposes of getting access to the mutex object in the plugin, it has nothing to do with what variables you are trying to protect from multiple threads access.
So I can use the same Mutex object for all protection cases? Even if they occured somewhere else. Given that I have a reference to IPlug of course. But if I don't, then it doesn't matter if I create more mutexes? I can merely use them just like I used the one in the IPlug?

Or i.e. the mutex does not relate to the object that contains it? It's merely based there by some convenience? Couldn't I then use one global mutex for all mutex locking?
mviljamaa is offline   Reply With Quote