Prevent deadlock shared boost mutex
<p>I want to use a shared mutex so threads only get locked when a vector/map/whatever is written to rather than read from. But I think func2() will never get the uniqueue lock because func1() will never get to unlock. Is there any way to not count a same-thread lock on shared_mutex when trying to get the uniqueue lock? Or would the problem still occur even then? </p>

<p>I'm guessing I need to find a way to force-get the lock (one thread at a time) once all threads have reached func2() OR have released the lock.</p>

<pre><code>func2()
{
    boost::unique_lock&lt;boost::shared_mutex&gt; lock_access3(shared_mutex);
    /*stuff*/
    lock_access3.unlock(); 
}

func1()
{
    boost::shared_lock&lt;boost::shared_mutex&gt; lock_access1(shared_mutex);
    func2();
    lock_access1.unlock();
}
</code></pre>
