« Return to Thread: boost mutex locks

Re: boost mutex locks

by Rush Manbert :: Rate this Message:

Reply to Author | View in Thread


On Jul 15, 2009, at 4:53 AM, mike_wilson wrote:

<snip>

> 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?
>
> 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?
>
You are correct. There is, however, a variant of mutex that allows for  
multiple readers to hold the lock simultaneously, but there can only  
be a single writer. All readers or other writers are locked out until  
the writer releases the lock. But if you mostly read this can reduce  
contention.

- Rush

_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

smime.p7s (3K) Download Attachment

 « Return to Thread: boost mutex locks