Boost logo

Boost Users :

Subject: Re: [Boost-users] boost mutex locks
From: Rush Manbert (rush_at_[hidden])
Date: 2009-07-15 12:46:42


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