From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2008-05-30 10:08:57
Frank Mori Hess <frank.hess_at_[hidden]> writes:
> On Friday 30 May 2008 06:40 am, Anthony Williams wrote:
>> > It would also be possible, I think, to make an adapter that actually
>> > creates a shared mutex from a normal one. I've never had to write a
>> > read/write mutex but I guess that this is how they are implemented
>> > internally.
>> It's a bit more complicated than that. boost::shared_mutex is
>> implemented on top of boost::mutex and boost::condition_variable for
>> pthreads: take a look.
> Hmm, so it looks like it would be straightforward to convert the pthread
> implementation of shared_mutex into an adapter that can convert an arbitrary
> mutex type (conforming to the boost.thread Lockable concept) into a shared
> mutex, by turning its boost::mutex into a template type?
No, I don't think so. The internal mutex within shared_mutex is only
locked within the member functions, and it is required to be exclusive
in order to protect the internal data.
When you call shared_lock, the only sense in which this thread holds a
mutex is that the internal state of the shared_mutex reflects that.
-- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk