Boost logo

Boost :

From: Wayne Miller (wcm_at_[hidden])
Date: 2001-04-24 22:49:05

    The uploaded example was Read Priority. I've got Write-Priority and
Equal-Priority implementations too that share the same interface.

    It would be trivial to extend the interface of the class to support:

    lock_read() const
    unlock_read() const

(Or something similar)

    These could be implemented simply as inlined wrappers of the current

    I think it is convenient for all the locks (reader/writer and otherwise)
to share a common interface, so the developer can test the performance of
various locks merely by changing variable type (Strategized Locking Pattern,
"Pattern-Oriented Software Architecture, Vol 2, by Schidmt, Stal, Rohnert,
    In this case, you could choose to have a simple lock, run the
application, and then replace the simple lock with the reader-writer lock
and see if there was a performance improvement without "breaking" the code.
    If you have one lock with a lock() / unlock() interface, and another
lock with a lock_write() / unlock_write() interface, you will break your
code if you want to experiment.

    The implementation of a single unlock is not immediately obvious to me.
The const and non-const version are very different.

    If a read gets a write-lock, this is inefficient, but not a problem --
therefore, I think write-lock should be the default.
    If a writer gets a read-lock, this is a disaster that would not be
caught at compile time. I think a const-overloaded interface might help
protect against this.

-Wayne Miller

Boost list run by bdawes at, gregod at, cpdaniel at, john at