Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > bfea28f33e7373c31a33dc7387b2a0be > files > 143

loki-lib-doc-0.1.7-2.fc12.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Loki: Loki::MutexLocker Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
      <li><a href="classes.html"><span>Class&nbsp;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="a00192.html">Loki</a>::<a class="el" href="a00083.html">MutexLocker</a>
  </div>
</div>
<div class="contents">
<h1>Loki::MutexLocker Class Reference</h1><!-- doxytag: class="Loki::MutexLocker" --><code>#include &lt;LevelMutex.h&gt;</code>
<p>
<div class="dynheader">
Collaboration diagram for Loki::MutexLocker:</div>
<div class="dynsection">
<center><font size="2">[<a target="top" href="graph_legend.html">legend</a>]</font></center></div>

<p>
<a href="a00339.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00083.html#ae8699ba4423d83aff277149c9008ec8">MutexLocker</a> (volatile <a class="el" href="a00071.html">LevelMutexInfo</a> &amp;mutex, bool lock=true)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00083.html#aeffc60518694479ac9985ee1878ed0f">MutexLocker</a> (volatile <a class="el" href="a00071.html">LevelMutexInfo</a> &amp;mutex, unsigned int milliSeconds, bool lock=true)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="bab99d9acf93e5add22deb8cf7d04a09"></a><!-- doxytag: member="Loki::MutexLocker::~MutexLocker" ref="bab99d9acf93e5add22deb8cf7d04a09" args="(void)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00083.html#bab99d9acf93e5add22deb8cf7d04a09">~MutexLocker</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Destructs the locker, and determines if it needs to unlock the mutex. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00083.html#c929c01961dc1b2a2ee1a39333a79c0b">Lock</a> (void)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00083.html#f5ea31fe3fac046cf646722cc8befa09">Unlock</a> (void)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="231de9c6db22151209ab2537fc45c65e"></a><!-- doxytag: member="Loki::MutexLocker::IsLocked" ref="231de9c6db22151209ab2537fc45c65e" args="(void) const " -->
bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00083.html#231de9c6db22151209ab2537fc45c65e">IsLocked</a> (void) const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns true if the mutex is locked by this object. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="2b49f0c689ff6cb8e29f2d8963b041df"></a><!-- doxytag: member="Loki::MutexLocker::GetMutex" ref="2b49f0c689ff6cb8e29f2d8963b041df" args="(void) const " -->
const volatile <a class="el" href="a00071.html">LevelMutexInfo</a> &amp;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00083.html#2b49f0c689ff6cb8e29f2d8963b041df">GetMutex</a> (void) const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Provides access to mutex controlled by this. <br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
You can place an instance of this as a local variable inside a function to lock a single mutex. It will lock the mutex if no error occurs, or throw if one does happen. When the function ends, the destructor will determine if it needs to unlock the mutex. This RAII technique insures the mutex gets unlocked even when exceptions occur. <hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="ae8699ba4423d83aff277149c9008ec8"></a><!-- doxytag: member="Loki::MutexLocker::MutexLocker" ref="ae8699ba4423d83aff277149c9008ec8" args="(volatile LevelMutexInfo &amp;mutex, bool lock=true)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Loki::MutexLocker::MutexLocker           </td>
          <td>(</td>
          <td class="paramtype">volatile <a class="el" href="a00071.html">LevelMutexInfo</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>mutex</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>lock</em> = <code>true</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td><code> [explicit]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Creates an object to lock an unlock a mutex for a function. This will throw if an attempt to lock the mutex fails. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>mutex</em>&nbsp;</td><td>Reference to the mutex. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>lock</em>&nbsp;</td><td>True if function wants to lock the mutex as this gets constructed. </td></tr>
  </table>
</dl>

<p>References <a class="el" href="a00243.html#l00208">Loki::LevelMutexInfo::GetLevel()</a>, and <a class="el" href="a00071.html#c0e21e08ee9974533a4da5008452bd04">Loki::LevelMutexInfo::Lock()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</div>
</div><p>
<a class="anchor" name="aeffc60518694479ac9985ee1878ed0f"></a><!-- doxytag: member="Loki::MutexLocker::MutexLocker" ref="aeffc60518694479ac9985ee1878ed0f" args="(volatile LevelMutexInfo &amp;mutex, unsigned int milliSeconds, bool lock=true)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Loki::MutexLocker::MutexLocker           </td>
          <td>(</td>
          <td class="paramtype">volatile <a class="el" href="a00071.html">LevelMutexInfo</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>mutex</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&nbsp;</td>
          <td class="paramname"> <em>milliSeconds</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>lock</em> = <code>true</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Creates an object to lock an unlock a mutex for a function. This waits a specified amount of time for another thread to unlock the mutex if it is locked. This will throw if an attempt to lock the mutex fails. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>mutex</em>&nbsp;</td><td>Reference to the mutex. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>milliSeconds</em>&nbsp;</td><td>Amount of time to wait for another thread to unlock the mutex. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>lock</em>&nbsp;</td><td>True if function wants to lock the mutex as this gets constructed. </td></tr>
  </table>
</dl>

<p>References <a class="el" href="a00243.html#l00208">Loki::LevelMutexInfo::GetLevel()</a>, and <a class="el" href="a00071.html#c0e21e08ee9974533a4da5008452bd04">Loki::LevelMutexInfo::Lock()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="c929c01961dc1b2a2ee1a39333a79c0b"></a><!-- doxytag: member="Loki::MutexLocker::Lock" ref="c929c01961dc1b2a2ee1a39333a79c0b" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Loki::MutexLocker::Lock           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
You can call this to lock (or relock) a mutex. In theory, you can lock and unlock a mutex several times within a function in order to give other threads access to a resource while this function does not need it. <dl class="return" compact><dt><b>Returns:</b></dt><dd>True if mutex is locked by this, else false if not locked. </dd></dl>

<p>References <a class="el" href="a00071.html#c0e21e08ee9974533a4da5008452bd04">Loki::LevelMutexInfo::Lock()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</div>
</div><p>
<a class="anchor" name="f5ea31fe3fac046cf646722cc8befa09"></a><!-- doxytag: member="Loki::MutexLocker::Unlock" ref="f5ea31fe3fac046cf646722cc8befa09" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Loki::MutexLocker::Unlock           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
You can call this to unlock a mutex before the destructor does it. By unlocking the mutexes before returning, the function can do other operations without making other threads wait too long. <dl class="return" compact><dt><b>Returns:</b></dt><dd>True if unlocked by this, else false if not unlocked by this. (Which is not the same as whether the mutex itself is locked or not by another thread.) </dd></dl>

<p>References <a class="el" href="a00071.html#01c9af5cb0f6870585b864b4557e9242">Loki::LevelMutexInfo::Unlock()</a>.</p>

<p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>

</div>
</div><p>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="a00158.html">LevelMutex.h</a><li><a class="el" href="a00157.html">LevelMutex.cpp</a></ul>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 29 18:51:43 2009 for Loki by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>