15 Jul
2009
15 Jul
'09
2:30 p.m.
Say one thread accesses the SetMyObject() , given that there is a lock in the function, it will also lock the GetMyObject() blocking any other thread from calling?
Yes. To be more exact, it will block even if you try to access GetMyObject() from the same thread.
This kind of implies that wherever in the object there is a lock, any function owned by the object will be locked to any other thread trying to access. Is this correct?
I don't know what you mean by saying "function owned by the object", but the mechanism works as follows: when boost::mutex is locked, any additional attempt to lock it would block. Where to put a mutex and where to lock it - all these are matters of a higher-level design.