Boost logo

Boost Users :

Subject: Re: [Boost-users] boost mutex locks
From: Igor R (boost.lists_at_[hidden])
Date: 2009-07-15 10:30:32


> 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.


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