Brian Nantz
1. There could be nested locks and the RWL should handle unwinding them correctly. I see that recursive_mutex seems to handle that. Does shared_mutex handle that as well?
shared_mutex does not support nested locks by the same thread.
2. Is there a way to give a higher priority to writes? I am worried about the readers starving the writers, so I would like any pending writers to be given preference over pending readers.
If there are pending writers then new readers are queued. When the current lock is released (whether reader or writer) then writers + readers compete for the lock.
How can I get this functionality from the Boost thread library? If I need to build my own, what class do you recommend using as a base to build from?
You may actually better NOT using a read/write lock. The lock itself is a point of contention, and for many short-lived readers (the natural use of a read/write lock) the time locking/unlocking may be a significant portion of the overall execution time, especially on multi-core and multi-processor systems. Joe Duffy posted some timings on his blog: http://www.bluebytesoftware.com/blog/2009/02/21/AMoreScalableReaderwriterLoc... Anthony -- Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/ just::thread C++0x thread library http://www.stdthread.co.uk Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976