1 Star 0 Fork 0

mobangjack / memory

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
classfoonathan_1_1memory_1_1memory__pool.html 34.20 KB
一键复制 编辑 原始数据 按行查看 历史
Jonathan Müller 提交于 2020-05-05 17:04 . Update documentation
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
<!-- HTML header for doxygen 1.8.16-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.18"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>memory: memory_pool&lt; PoolType, BlockOrRawAllocator &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">memory
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="main-nav">
<ul class="sm sm-dox" id="main-menu">
<li><a href="index.html">Main Page</a></li>
<li><a href="md_doc_tutorial.html">Tutorial</a></li>
<li><a href="namespacefoonathan_1_1memory.html">Index</a></li>
<li><a href="files.html">Files</a></li>
</ul>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="namespacefoonathan.html">foonathan</a></li><li class="navelem"><a class="el" href="namespacefoonathan_1_1memory.html">memory</a></li><li class="navelem"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html">memory_pool</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-types">Typedefs</a> &#124;
<a href="#pub-static-attribs">Constants</a> &#124;
<a href="#pub-methods">Member Functions</a> </div>
<div class="headertitle">
<div class="title">memory_pool&lt; PoolType, BlockOrRawAllocator &gt; Class Template Reference<div class="ingroups"><a class="el" href="group__allocator.html">Allocator implementations</a></div></div> </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename PoolType = node_pool, class BlockOrRawAllocator = default_allocator&gt;<br />
class foonathan::memory::memory_pool&lt; PoolType, BlockOrRawAllocator &gt;</h3>
<p>A stateful <a href="md_doc_concepts.html#concept_rawallocator">RawAllocator</a> that manages <a href="md_doc_concepts.html#concept_node">nodes</a> of fixed size. </p>
<p>It uses a <a class="el" href="classfoonathan_1_1memory_1_1memory__arena.html">memory_arena</a> with a given <code>BlockOrRawAllocator</code> defaulting to <a class="el" href="classfoonathan_1_1memory_1_1growing__block__allocator.html">growing_block_allocator</a>, subdivides them in small nodes of given size and puts them onto a free list. Allocation and deallocation simply remove or add nodes from this list and are thus fast. The way the list is maintained can be controlled via the <code>PoolType</code> which is either <a class="el" href="structfoonathan_1_1memory_1_1node__pool.html">node_pool</a>, <a class="el" href="structfoonathan_1_1memory_1_1array__pool.html">array_pool</a> or <a class="el" href="structfoonathan_1_1memory_1_1small__node__pool.html">small_node_pool</a>.<br />
This kind of allocator is ideal for fixed size allocations and deallocations in any order, for example in a node based container like <code>std::list</code>. It is not so good for different allocation sizes and has some drawbacks for arrays as described in <a class="el" href="memory__pool__type_8hpp.html">memory_pool_type.hpp</a>. </p>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Typedefs</h2></td></tr>
<tr class="memitem:a7fd26a8539389ffa2a4b1d1a7b6b839c"><td class="memItemLeft" align="right" valign="top"><a id="a7fd26a8539389ffa2a4b1d1a7b6b839c"></a>
using&#160;</td><td class="memItemRight" valign="bottom"><b>allocator_type</b> = <a class="el" href="group__core.html#gaf1ce941b1306a592d4ebba1167fd98aa">make_block_allocator_t</a>&lt; BlockOrRawAllocator &gt;</td></tr>
<tr class="separator:a7fd26a8539389ffa2a4b1d1a7b6b839c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a57a387e63de9c0ba78a5f77675ff8eed"><td class="memItemLeft" align="right" valign="top"><a id="a57a387e63de9c0ba78a5f77675ff8eed"></a>
using&#160;</td><td class="memItemRight" valign="bottom"><b>pool_type</b> = PoolType</td></tr>
<tr class="separator:a57a387e63de9c0ba78a5f77675ff8eed"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-attribs"></a>
Constants</h2></td></tr>
<tr class="memitem:ac2f4915e6d7c56b719fd1a45fb39baf3"><td class="memItemLeft" align="right" valign="top"><a id="ac2f4915e6d7c56b719fd1a45fb39baf3"></a>
static constexpr std::size_t&#160;</td><td class="memItemRight" valign="bottom"><b>min_node_size</b></td></tr>
<tr class="separator:ac2f4915e6d7c56b719fd1a45fb39baf3"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Member Functions</h2></td></tr>
<tr class="memitem:a0d33c9ac4c7dbac1782f619a9eec2db8"><td class="memTemplParams" colspan="2">template&lt;typename... Args&gt; </td></tr>
<tr class="memitem:a0d33c9ac4c7dbac1782f619a9eec2db8"><td class="memTemplItemLeft" align="right" valign="top">&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a0d33c9ac4c7dbac1782f619a9eec2db8">memory_pool</a> (std::size_t <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a5d4e471c06eda1a92506955593a4fd7b">node_size</a>, std::size_t block_size, Args &amp;&amp;... args)</td></tr>
<tr class="separator:a0d33c9ac4c7dbac1782f619a9eec2db8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aba9c8011345cf151a707e7989e1ef521"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#aba9c8011345cf151a707e7989e1ef521">~memory_pool</a> () noexcept</td></tr>
<tr class="separator:aba9c8011345cf151a707e7989e1ef521"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aea24233cc1a3d57ad06a749cc548abdb"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#aea24233cc1a3d57ad06a749cc548abdb">allocate_node</a> ()</td></tr>
<tr class="separator:aea24233cc1a3d57ad06a749cc548abdb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a508dd5fbab863e311e289112cdff924b"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a508dd5fbab863e311e289112cdff924b">try_allocate_node</a> () noexcept</td></tr>
<tr class="separator:a508dd5fbab863e311e289112cdff924b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a634628f2fb08da33a23f1611e7103527"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a634628f2fb08da33a23f1611e7103527">allocate_array</a> (std::size_t n)</td></tr>
<tr class="separator:a634628f2fb08da33a23f1611e7103527"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad61bb3867173270d1341f18194af8300"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#ad61bb3867173270d1341f18194af8300">try_allocate_array</a> (std::size_t n) noexcept</td></tr>
<tr class="separator:ad61bb3867173270d1341f18194af8300"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a53347e3af0df64804fa25ab1482fa0bd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a53347e3af0df64804fa25ab1482fa0bd">deallocate_node</a> (void *ptr) noexcept</td></tr>
<tr class="separator:a53347e3af0df64804fa25ab1482fa0bd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a72c9901827edcc731c4e69271ec03de9"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a72c9901827edcc731c4e69271ec03de9">try_deallocate_node</a> (void *ptr) noexcept</td></tr>
<tr class="separator:a72c9901827edcc731c4e69271ec03de9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a23ee5abed4a79390885e45c7dcb1a663"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a23ee5abed4a79390885e45c7dcb1a663">deallocate_array</a> (void *ptr, std::size_t n) noexcept</td></tr>
<tr class="separator:a23ee5abed4a79390885e45c7dcb1a663"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9c4fdd8288a6f31eb2951bb784973af0"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a9c4fdd8288a6f31eb2951bb784973af0">try_deallocate_array</a> (void *ptr, std::size_t n) noexcept</td></tr>
<tr class="separator:a9c4fdd8288a6f31eb2951bb784973af0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5d4e471c06eda1a92506955593a4fd7b"><td class="memItemLeft" align="right" valign="top">std::size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a5d4e471c06eda1a92506955593a4fd7b">node_size</a> () const noexcept</td></tr>
<tr class="separator:a5d4e471c06eda1a92506955593a4fd7b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a97da77ca5a46e5e3088d6c0637b52af7"><td class="memItemLeft" align="right" valign="top">std::size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a97da77ca5a46e5e3088d6c0637b52af7">capacity_left</a> () const noexcept</td></tr>
<tr class="separator:a97da77ca5a46e5e3088d6c0637b52af7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af4fe037332aabd13253517d22394da73"><td class="memItemLeft" align="right" valign="top">std::size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#af4fe037332aabd13253517d22394da73">next_capacity</a> () const noexcept</td></tr>
<tr class="separator:af4fe037332aabd13253517d22394da73"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3ae445687ecb4a037b542ede5c6f48ac"><td class="memItemLeft" align="right" valign="top">allocator_type &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a3ae445687ecb4a037b542ede5c6f48ac">get_allocator</a> () noexcept</td></tr>
<tr class="separator:a3ae445687ecb4a037b542ede5c6f48ac"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader"></div></td></tr>
<tr class="memitem:ae0494fe4151c1ff8e07aa6e446897507"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#ae0494fe4151c1ff8e07aa6e446897507">memory_pool</a> (<a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html">memory_pool</a> &amp;&amp;other) noexcept</td></tr>
<tr class="separator:ae0494fe4151c1ff8e07aa6e446897507"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad5a43ee95003c599ac661dc9c4b61102"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html">memory_pool</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#ad5a43ee95003c599ac661dc9c4b61102">operator=</a> (<a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html">memory_pool</a> &amp;&amp;other) noexcept</td></tr>
<tr class="separator:ad5a43ee95003c599ac661dc9c4b61102"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Constructors</h2>
<a id="a0d33c9ac4c7dbac1782f619a9eec2db8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0d33c9ac4c7dbac1782f619a9eec2db8">&#9670;&nbsp;</a></span>memory_pool() <span class="overload">[1/2]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html">memory_pool</a> </td>
<td>(</td>
<td class="paramtype">std::size_t&#160;</td>
<td class="paramname"><em>node_size</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">std::size_t&#160;</td>
<td class="paramname"><em>block_size</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">Args &amp;&amp;...&#160;</td>
<td class="paramname"><em>args</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Creates it by specifying the size each <a href="md_doc_concepts.html#concept_node">node</a> will have, the initial block size for the arena and other constructor arguments for the <a href="md_doc_concepts.html#concept_blockallocator">BlockAllocator</a>. If the <code>node_size</code> is less than the <code>min_node_size</code>, the <code>min_node_size</code> will be the actual node size. It will allocate an initial memory block with given size from the <a href="md_doc_concepts.html#concept_blockallocator">BlockAllocator</a> and puts it onto the free list. </dd></dl>
<dl class="section user"><dt>Requires:</dt><dd><code>node_size</code> must be a valid <a href="md_doc_concepts.html#concept_node">node size</a> and <code>block_size</code> must be a non-zero value. </dd></dl>
</div>
</div>
<a id="aba9c8011345cf151a707e7989e1ef521"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aba9c8011345cf151a707e7989e1ef521">&#9670;&nbsp;</a></span>~memory_pool()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">~<a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html">memory_pool</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Destroys the <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html">memory_pool</a> by returning all memory blocks, regardless of properly deallocated back to the <a href="md_doc_concepts.html#concept_blockallocator">BlockAllocator</a>. </dd></dl>
</div>
</div>
<a id="ae0494fe4151c1ff8e07aa6e446897507"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae0494fe4151c1ff8e07aa6e446897507">&#9670;&nbsp;</a></span>memory_pool() <span class="overload">[2/2]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html">memory_pool</a> </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html">memory_pool</a>&lt; PoolType, BlockOrRawAllocator &gt; &amp;&amp;&#160;</td>
<td class="paramname"><em>other</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Moving a <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html">memory_pool</a> object transfers ownership over the free list, i.e. the moved from pool is completely empty and the new one has all its memory. That means that it is not allowed to call <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a53347e3af0df64804fa25ab1482fa0bd">deallocate_node()</a> on a moved-from allocator even when passing it memory that was previously allocated by this object. </dd></dl>
</div>
</div>
<h2 class="groupheader">Member Functions</h2>
<a id="ad5a43ee95003c599ac661dc9c4b61102"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad5a43ee95003c599ac661dc9c4b61102">&#9670;&nbsp;</a></span>operator=()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html">memory_pool</a>&amp; operator= </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html">memory_pool</a>&lt; PoolType, BlockOrRawAllocator &gt; &amp;&amp;&#160;</td>
<td class="paramname"><em>other</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Moving a <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html">memory_pool</a> object transfers ownership over the free list, i.e. the moved from pool is completely empty and the new one has all its memory. That means that it is not allowed to call <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a53347e3af0df64804fa25ab1482fa0bd">deallocate_node()</a> on a moved-from allocator even when passing it memory that was previously allocated by this object. </dd></dl>
</div>
</div>
<a id="aea24233cc1a3d57ad06a749cc548abdb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aea24233cc1a3d57ad06a749cc548abdb">&#9670;&nbsp;</a></span>allocate_node()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void* allocate_node </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Allocates a single <a href="md_doc_concepts.html#concept_node">node</a> by removing it from the free list. If the free list is empty, a new memory block will be allocated from the arena and put onto it. The new block size will be <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#af4fe037332aabd13253517d22394da73">next_capacity()</a> big. </dd></dl>
<dl class="section user"><dt>Returns:</dt><dd>A node of size <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a5d4e471c06eda1a92506955593a4fd7b">node_size()</a> suitable aligned, i.e. suitable for any type where <code>sizeof(T) &lt; node_size()</code>. </dd></dl>
<dl class="section user"><dt>Throws:</dt><dd>Anything thrown by the used <a href="md_doc_concepts.html#concept_blockallocator">BlockAllocator</a>'s allocation function if a growth is needed. </dd></dl>
</div>
</div>
<a id="a508dd5fbab863e311e289112cdff924b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a508dd5fbab863e311e289112cdff924b">&#9670;&nbsp;</a></span>try_allocate_node()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void* try_allocate_node </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Allocates a single <a href="md_doc_concepts.html#concept_node">node</a> similar to <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#aea24233cc1a3d57ad06a749cc548abdb">allocate_node()</a>. But if the free list is empty, a new block will <em>not</em> be allocated. </dd></dl>
<dl class="section user"><dt>Returns:</dt><dd>A suitable aligned node of size <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a5d4e471c06eda1a92506955593a4fd7b">node_size()</a> or <code>nullptr</code>. </dd></dl>
</div>
</div>
<a id="a634628f2fb08da33a23f1611e7103527"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a634628f2fb08da33a23f1611e7103527">&#9670;&nbsp;</a></span>allocate_array()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void* allocate_array </td>
<td>(</td>
<td class="paramtype">std::size_t&#160;</td>
<td class="paramname"><em>n</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Allocates an <a href="md_doc_concepts.html#concept_array">array</a> of nodes by searching for <code>n</code> continuous nodes on the list and removing them. Depending on the <code>PoolType</code> this can be a slow operation or not allowed at all. This can sometimes lead to a growth, even if technically there is enough continuous memory on the free list. </dd></dl>
<dl class="section user"><dt>Returns:</dt><dd>An array of <code>n</code> nodes of size <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a5d4e471c06eda1a92506955593a4fd7b">node_size()</a> suitable aligned. </dd></dl>
<dl class="section user"><dt>Throws:</dt><dd>Anything thrown by the used <a href="md_doc_concepts.html#concept_blockallocator">BlockAllocator</a>'s allocation function if a growth is needed, or <a class="el" href="classfoonathan_1_1memory_1_1bad__array__size.html">bad_array_size</a> if <code>n * node_size()</code> is too big. </dd></dl>
<dl class="section user"><dt>Requires:</dt><dd><code>n</code> must be valid <a href="md_doc_concepts.html#concept_array">array count</a>. </dd></dl>
</div>
</div>
<a id="ad61bb3867173270d1341f18194af8300"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad61bb3867173270d1341f18194af8300">&#9670;&nbsp;</a></span>try_allocate_array()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void* try_allocate_array </td>
<td>(</td>
<td class="paramtype">std::size_t&#160;</td>
<td class="paramname"><em>n</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Allocates an <a href="md_doc_concepts.html#concept_array">array</a> of nodes similar to <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a634628f2fb08da33a23f1611e7103527">allocate_array()</a>. But it will never allocate a new memory block. </dd></dl>
<dl class="section user"><dt>Returns:</dt><dd>An array of <code>n</code> nodes of size <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a5d4e471c06eda1a92506955593a4fd7b">node_size()</a> suitable aligned or <code>nullptr</code>. </dd></dl>
</div>
</div>
<a id="a53347e3af0df64804fa25ab1482fa0bd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a53347e3af0df64804fa25ab1482fa0bd">&#9670;&nbsp;</a></span>deallocate_node()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void deallocate_node </td>
<td>(</td>
<td class="paramtype">void *&#160;</td>
<td class="paramname"><em>ptr</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Deallocates a single <a href="md_doc_concepts.html#concept_node">node</a> by putting it back onto the free list. </dd></dl>
<dl class="section user"><dt>Requires:</dt><dd><code>ptr</code> must be a result from a previous call to <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#aea24233cc1a3d57ad06a749cc548abdb">allocate_node()</a> on the same free list, i.e. either this allocator object or a new object created by moving this to it. </dd></dl>
</div>
</div>
<a id="a72c9901827edcc731c4e69271ec03de9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a72c9901827edcc731c4e69271ec03de9">&#9670;&nbsp;</a></span>try_deallocate_node()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">bool try_deallocate_node </td>
<td>(</td>
<td class="paramtype">void *&#160;</td>
<td class="paramname"><em>ptr</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Deallocates a single <a href="md_doc_concepts.html#concept_node">node</a> but it does not be a result of a previous call to <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#aea24233cc1a3d57ad06a749cc548abdb">allocate_node()</a>. </dd></dl>
<dl class="section user"><dt>Returns:</dt><dd><code>true</code> if the node could be deallocated, <code>false</code> otherwise. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>Some free list implementations can deallocate any memory, doesn't matter where it is coming from. </dd></dl>
</div>
</div>
<a id="a23ee5abed4a79390885e45c7dcb1a663"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a23ee5abed4a79390885e45c7dcb1a663">&#9670;&nbsp;</a></span>deallocate_array()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void deallocate_array </td>
<td>(</td>
<td class="paramtype">void *&#160;</td>
<td class="paramname"><em>ptr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">std::size_t&#160;</td>
<td class="paramname"><em>n</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Deallocates an <a href="md_doc_concepts.html#concept_array">array</a> by putting it back onto the free list. </dd></dl>
<dl class="section user"><dt>Requires:</dt><dd><code>ptr</code> must be a result from a previous call to <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a634628f2fb08da33a23f1611e7103527">allocate_array()</a> with the same <code>n</code> on the same free list, i.e. either this allocator object or a new object created by moving this to it. </dd></dl>
</div>
</div>
<a id="a9c4fdd8288a6f31eb2951bb784973af0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9c4fdd8288a6f31eb2951bb784973af0">&#9670;&nbsp;</a></span>try_deallocate_array()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">bool try_deallocate_array </td>
<td>(</td>
<td class="paramtype">void *&#160;</td>
<td class="paramname"><em>ptr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">std::size_t&#160;</td>
<td class="paramname"><em>n</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Deallocates an <a href="md_doc_concepts.html#concept_array">array</a> but it does not be a result of a previous call to <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a634628f2fb08da33a23f1611e7103527">allocate_array()</a>. </dd></dl>
<dl class="section user"><dt>Returns:</dt><dd><code>true</code> if the node could be deallocated, <code>false</code> otherwise. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>Some free list implementations can deallocate any memory, doesn't matter where it is coming from. </dd></dl>
</div>
</div>
<a id="a5d4e471c06eda1a92506955593a4fd7b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5d4e471c06eda1a92506955593a4fd7b">&#9670;&nbsp;</a></span>node_size()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">std::size_t node_size </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Returns:</dt><dd>The size of each <a href="md_doc_concepts.html#concept_node">node</a> in the pool, this is either the same value as in the constructor or <code>min_node_size</code> if the value was too small. </dd></dl>
</div>
</div>
<a id="a97da77ca5a46e5e3088d6c0637b52af7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a97da77ca5a46e5e3088d6c0637b52af7">&#9670;&nbsp;</a></span>capacity_left()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">std::size_t capacity_left </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Effects:</dt><dd>Returns the total amount of bytes remaining on the free list. Divide it by <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a5d4e471c06eda1a92506955593a4fd7b">node_size()</a> to get the number of nodes that can be allocated without growing the arena. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>Array allocations may lead to a growth even if the capacity_left left is big enough. </dd></dl>
</div>
</div>
<a id="af4fe037332aabd13253517d22394da73"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af4fe037332aabd13253517d22394da73">&#9670;&nbsp;</a></span>next_capacity()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">std::size_t next_capacity </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Returns:</dt><dd>The size of the next memory block after the free list gets empty and the arena grows. <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a97da77ca5a46e5e3088d6c0637b52af7">capacity_left()</a> will increase by this amount. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>Due to fence memory in debug mode this cannot be just divided by the <a class="el" href="classfoonathan_1_1memory_1_1memory__pool.html#a5d4e471c06eda1a92506955593a4fd7b">node_size()</a> to get the number of nodes. </dd></dl>
</div>
</div>
<a id="a3ae445687ecb4a037b542ede5c6f48ac"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3ae445687ecb4a037b542ede5c6f48ac">&#9670;&nbsp;</a></span>get_allocator()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">allocator_type&amp; get_allocator </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section user"><dt>Returns:</dt><dd>A reference to the <a href="md_doc_concepts.html#concept_blockallocator">BlockAllocator</a> used for managing the arena. </dd></dl>
<dl class="section user"><dt>Requires:</dt><dd>It is undefined behavior to move this allocator out into another object. </dd></dl>
</div>
</div>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.16-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.18
</small></address>
</body>
</html>
1
https://gitee.com/mobangjack/memory.git
git@gitee.com:mobangjack/memory.git
mobangjack
memory
memory
gh-pages

搜索帮助