|
Boost : |
From: Batov, Vladimir (Vladimir.Batov_at_[hidden])
Date: 2004-06-28 00:21:55
John Torjo wrote:
> Batov, Vladimir wrote:
>>
>> class writer_lock : public boost::mutex::scoped_lock
>> {
>> typedef boost::mutex::scoped_lock super;
>>
>> public:
>>
>> writer_lock(rw_mutex& mutex) : super(mutex.mutex_),
mutex_(mutex)
>> {
>> ++mutex_.num_writers_; // Make new readers wait.
> ^^^^
>
> just curios, shouldn't this be thread-safe?
I believe it is thread-safe as writer_lock currently inherits from
scoped_lock and, consequently, we get inside the writer_lock constructor
after its base-class scoped_lock constructor. The base-class constructor
does the synchronization.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk