Utilities for creating a lock hierarchy?
<p>According to the answers found in <a href="http://stackoverflow.com/questions/1892619/threads-and-simple-dead-lock-cure">Threads and simple Dead lock cure</a> and also <a href="http://drdobbs.com/article/print?articleId=204801163&amp;siteSectionName=" rel="nofollow">Herb Sutter</a> the key to avoiding deadlock is by using lock hierarchies.</p>

<p>Are there any good C++ libraries that provide support for this? I can't find any in Boost or Poco.</p>

<p>Ideally it would be a system that allows one to define the hierarchy at compile-time. Perhaps it would look like this:</p>

<pre><code>template&lt;class LowerLevelMutex&gt;
class RankedMutex { ... };

class BottomMutex { ... };

typedef RankedMutex&lt;BottomMutex&gt; L1Mutex;
typedef RankedMutex&lt;L1Mutex&gt; L2Mutex;
typedef RankedMutex&lt;L2Mutex&gt; L3Mutex;
// ...
</code></pre>
