title: Interprocess reader/writer lock with Boost
body: <p><a href="https://stackoverflow.com/questions/989795/example-for-boost-shared-mutex-multiple-reads-one-write">This thread</a> is gold when it comes to explaining how to implement reader/writer locks with Boost. It seems relatively simple and I really love it but it also seems to be using a non-named lock and I need an interprocess solution (doesn't need to be portable, can be Windows-only).</p>
  
  <p>Is there a way to have an interprocess <code>shared_mutex</code>? I see there is a <a href="http://www.boost.org/doc/libs/1_35_0/doc/html/boost/interprocess/named_mutex.html" rel="nofollow noreferrer"><code>named_mutex</code></a> but I can't get it to work with <a href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.locks.shared_lock" rel="nofollow noreferrer"><code>shared_lock</code></a> ot other locks.</p>
  
  <p>Any pointers are appreciated.</p>
  
  <p>[EDIT]</p>
  
  <p>In the meantime, I have come across <a href="https://stackoverflow.com/questions/4157491/is-there-an-upgrade-to-unique-lock-for-boostinterprocess-resolved">this thread</a> which almost hits the nail on the head. I have two issues: </p>
  
  <ol>
  <li>it doesn't show complete code (I am guessing I need to use <code>named_upgradable_mutex</code> but I am not quite sure) and </li>
  <li>I don't like the answer for the modified "writer" which uses no off the shelf class that does unlocking in destructor but a sequence of 3 raw calls on the mutex.</li>
  </ol>
  
  <p>Comments or good solutions are still welcome.</p>