Sophie

Sophie

distrib > Mandriva > 2011.0 > i586 > by-pkgid > 092973e3430682b17a7d74261285ae23 > files > 201

loki-lib-doc-0.1.7-1.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::SmallObjAllocator 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="a00127.html">SmallObjAllocator</a>
  </div>
</div>
<div class="contents">
<h1>Loki::SmallObjAllocator Class Reference<br>
<small>
[<a class="el" href="a00217.html">Internals</a>]</small>
</h1><!-- doxytag: class="Loki::SmallObjAllocator" --><code>#include &lt;SmallObj.h&gt;</code>
<p>
<div class="dynheader">
Inheritance diagram for Loki::SmallObjAllocator:</div>
<div class="dynsection">
<center><font size="2">[<a target="top" href="graph_legend.html">legend</a>]</font></center></div>
<div class="dynheader">
Collaboration diagram for Loki::SmallObjAllocator:</div>
<div class="dynsection">
<center><font size="2">[<a target="top" href="graph_legend.html">legend</a>]</font></center></div>

<p>
<a href="a00394.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">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00127.html#a41bb717d552cd0df57a941def7ec607">Allocate</a> (std::size_t size, bool doThrow)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00127.html#2b669733cfa9dd157603d13d979f8c1c">Deallocate</a> (void *p, std::size_t size)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00127.html#50406896d75a2591d4bd7dc53325e3d6">Deallocate</a> (void *p)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="e49e9de3fd7b2fd93676cc1d63299b0d"></a><!-- doxytag: member="Loki::SmallObjAllocator::GetMaxObjectSize" ref="e49e9de3fd7b2fd93676cc1d63299b0d" args="() const " -->
std::size_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00127.html#e49e9de3fd7b2fd93676cc1d63299b0d">GetMaxObjectSize</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns max # of bytes which this can allocate. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="b1c8a2a3d7e9368ab59422ddd082105c"></a><!-- doxytag: member="Loki::SmallObjAllocator::GetAlignment" ref="b1c8a2a3d7e9368ab59422ddd082105c" args="() const " -->
std::size_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00127.html#b1c8a2a3d7e9368ab59422ddd082105c">GetAlignment</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns # of bytes between allocation boundaries. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00127.html#6b635664b20a6984303dabde86c8ac83">TrimExcessMemory</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="a00127.html#2b7fbd5bf5fc56e45754abd2497ad18f">IsCorrupt</a> (void) const </td></tr>

<tr><td colspan="2"><br><h2>Protected 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="a00127.html#3d40b34b1a2d08a6bb9d9fa22ab5ce24">SmallObjAllocator</a> (std::size_t pageSize, std::size_t maxObjectSize, std::size_t objectAlignSize)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00127.html#0c861c4605844ee30dbe2a4f533fe2ae">~SmallObjAllocator</a> (void)</td></tr>

</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Manages pool of fixed-size allocators. Designed to be a non-templated base class of <a class="el" href="a00002.html">AllocatorSingleton</a> so that implementation details can be safely hidden in the source code file. <hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="3d40b34b1a2d08a6bb9d9fa22ab5ce24"></a><!-- doxytag: member="Loki::SmallObjAllocator::SmallObjAllocator" ref="3d40b34b1a2d08a6bb9d9fa22ab5ce24" args="(std::size_t pageSize, std::size_t maxObjectSize, std::size_t objectAlignSize)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Loki::SmallObjAllocator::SmallObjAllocator           </td>
          <td>(</td>
          <td class="paramtype">std::size_t&nbsp;</td>
          <td class="paramname"> <em>pageSize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::size_t&nbsp;</td>
          <td class="paramname"> <em>maxObjectSize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::size_t&nbsp;</td>
          <td class="paramname"> <em>objectAlignSize</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
The only available constructor needs certain parameters in order to initialize all the FixedAllocator's. This throws only if <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>pageSize</em>&nbsp;</td><td># of bytes in a page of memory. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>maxObjectSize</em>&nbsp;</td><td>Max # of bytes which this may allocate. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>objectAlignSize</em>&nbsp;</td><td># of bytes between alignment boundaries. </td></tr>
  </table>
</dl>

<p>References <a class="el" href="a00261.html#l01013">Loki::GetOffset()</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="0c861c4605844ee30dbe2a4f533fe2ae"></a><!-- doxytag: member="Loki::SmallObjAllocator::~SmallObjAllocator" ref="0c861c4605844ee30dbe2a4f533fe2ae" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Loki::SmallObjAllocator::~SmallObjAllocator           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Destructor releases all blocks, all Chunks, and FixedAllocator's. Any outstanding blocks are unavailable, and should not be used after this destructor is called. The destructor is deliberately non-virtual because it is protected, not public. 
</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="a41bb717d552cd0df57a941def7ec607"></a><!-- doxytag: member="Loki::SmallObjAllocator::Allocate" ref="a41bb717d552cd0df57a941def7ec607" args="(std::size_t size, bool doThrow)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void * Loki::SmallObjAllocator::Allocate           </td>
          <td>(</td>
          <td class="paramtype">std::size_t&nbsp;</td>
          <td class="paramname"> <em>size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>doThrow</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Allocates a block of memory of requested size. Complexity is often constant-time, but might be O(C) where C is the number of Chunks in a <a class="el" href="a00056.html">FixedAllocator</a>.<p>
<dl class="user" compact><dt><b>Exception Safety Level</b></dt><dd>Provides either strong-exception safety, or no-throw exception-safety level depending upon doThrow parameter. The reason it provides two levels of exception safety is because it is used by both the nothrow and throwing new operators. The underlying implementation will never throw of its own accord, but this can decide to throw if it does not allocate. The only exception it should emit is std::bad_alloc.</dd></dl>
<dl class="user" compact><dt><b>Allocation Failure</b></dt><dd>If it does not allocate, it will call TrimExcessMemory and attempt to allocate again, before it decides to throw or return NULL. Many allocators loop through several new_handler functions, and terminate if they can not allocate, but not this one. It only makes one attempt using its own implementation of the new_handler, and then returns NULL or throws so that the program can decide what to do at a higher level. (Side note: Even though the C++ Standard allows allocators and new_handlers to terminate if they fail, the <a class="el" href="a00192.html">Loki</a> allocator does not do that since that policy is not polite to a host program.)</dd></dl>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>size</em>&nbsp;</td><td># of bytes needed for allocation. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>doThrow</em>&nbsp;</td><td>True if this should throw if unable to allocate, false if it should provide no-throw exception safety level. </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>NULL if nothing allocated and doThrow is false. Else the pointer to an available block of memory. </dd></dl>

<p>References <a class="el" href="a00261.html#l00831">Loki::FixedAllocator::Allocate()</a>, <a class="el" href="a00261.html#l00256">Loki::FixedAllocator::BlockSize()</a>, <a class="el" href="a00261.html#l01028">Loki::DefaultAllocator()</a>, <a class="el" href="a00262.html#l00157">GetAlignment()</a>, <a class="el" href="a00262.html#l00153">GetMaxObjectSize()</a>, <a class="el" href="a00261.html#l01013">Loki::GetOffset()</a>, and <a class="el" href="a00261.html#l01088">TrimExcessMemory()</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="50406896d75a2591d4bd7dc53325e3d6"></a><!-- doxytag: member="Loki::SmallObjAllocator::Deallocate" ref="50406896d75a2591d4bd7dc53325e3d6" args="(void *p)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Loki::SmallObjAllocator::Deallocate           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>p</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Deallocates a block of memory at a given place but of unknown size size. Complexity is O(F + C) where F is the count of FixedAllocator's in the pool, and C is the number of Chunks in all FixedAllocator's. This does not throw exceptions. This overloaded version of Deallocate is called by the nothow delete operator - which is called when the nothrow new operator is used, but a constructor throws an exception. 
<p>References <a class="el" href="a00261.html#l00888">Loki::FixedAllocator::Deallocate()</a>, <a class="el" href="a00261.html#l01049">Loki::DefaultDeallocator()</a>, <a class="el" href="a00262.html#l00157">GetAlignment()</a>, <a class="el" href="a00262.html#l00153">GetMaxObjectSize()</a>, <a class="el" href="a00261.html#l01013">Loki::GetOffset()</a>, and <a class="el" href="a00261.html#l00722">Loki::FixedAllocator::HasBlock()</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="2b669733cfa9dd157603d13d979f8c1c"></a><!-- doxytag: member="Loki::SmallObjAllocator::Deallocate" ref="2b669733cfa9dd157603d13d979f8c1c" args="(void *p, std::size_t size)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Loki::SmallObjAllocator::Deallocate           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::size_t&nbsp;</td>
          <td class="paramname"> <em>size</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Deallocates a block of memory at a given place and of a specific size. Complexity is almost always constant-time, and is O(C) only if it has to search for which <a class="el" href="a00025.html">Chunk</a> deallocates. This never throws. 
<p>References <a class="el" href="a00261.html#l00256">Loki::FixedAllocator::BlockSize()</a>, <a class="el" href="a00261.html#l00888">Loki::FixedAllocator::Deallocate()</a>, <a class="el" href="a00261.html#l01049">Loki::DefaultDeallocator()</a>, <a class="el" href="a00262.html#l00157">GetAlignment()</a>, <a class="el" href="a00262.html#l00153">GetMaxObjectSize()</a>, and <a class="el" href="a00261.html#l01013">Loki::GetOffset()</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="2b7fbd5bf5fc56e45754abd2497ad18f"></a><!-- doxytag: member="Loki::SmallObjAllocator::IsCorrupt" ref="2b7fbd5bf5fc56e45754abd2497ad18f" args="(void) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Loki::SmallObjAllocator::IsCorrupt           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Returns true if anything in implementation is corrupt. Complexity is O(F + C + B) where F is the count of FixedAllocator's in the pool, C is the number of Chunks in all FixedAllocator's, and B is the number of blocks in all Chunks. If it determines any data is corrupted, this will return true in release version, but assert in debug version at the line where it detects the corrupted data. If it does not detect any corrupted data, it returns false. 
<p>References <a class="el" href="a00262.html#l00157">GetAlignment()</a>, <a class="el" href="a00262.html#l00153">GetMaxObjectSize()</a>, and <a class="el" href="a00261.html#l01013">Loki::GetOffset()</a>.</p>

<p>Referenced by <a class="el" href="a00262.html#l00303">Loki::AllocatorSingleton&lt; ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy &gt;::IsCorrupted()</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="6b635664b20a6984303dabde86c8ac83"></a><!-- doxytag: member="Loki::SmallObjAllocator::TrimExcessMemory" ref="6b635664b20a6984303dabde86c8ac83" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Loki::SmallObjAllocator::TrimExcessMemory           </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>
Releases empty Chunks from memory. Complexity is O(F + C) where F is the count of FixedAllocator's in the pool, and C is the number of Chunks in all FixedAllocator's. This will never throw. This is called by AllocatorSingleto::ClearExtraMemory, the new_handler function for Loki's allocator, and is called internally when an allocation fails. <dl class="return" compact><dt><b>Returns:</b></dt><dd>True if any memory released, or false if none released. </dd></dl>

<p>References <a class="el" href="a00262.html#l00157">GetAlignment()</a>, <a class="el" href="a00262.html#l00153">GetMaxObjectSize()</a>, and <a class="el" href="a00261.html#l01013">Loki::GetOffset()</a>.</p>

<p>Referenced by <a class="el" href="a00261.html#l01109">Allocate()</a>, and <a class="el" href="a00262.html#l00287">Loki::AllocatorSingleton&lt; ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy &gt;::ClearExtraMemory()</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>SmallObj.h<li>SmallObj.cpp</ul>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 29 18:51:45 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>