diff options
author | Benjamin Kosnik <bkoz@redhat.com> | 2004-07-14 06:37:17 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2004-07-14 06:37:17 +0000 |
commit | 780028b6cff77a9f25f75a24047ab5f3b50a4834 (patch) | |
tree | cdb983cd86b1e1afba9b2e5cf5c1ce3c19e347c9 /libstdc++-v3/docs | |
parent | 70049c7ce2da027e60dd09995f37ed2548e35c53 (diff) | |
download | gcc-780028b6cff77a9f25f75a24047ab5f3b50a4834.zip gcc-780028b6cff77a9f25f75a24047ab5f3b50a4834.tar.gz gcc-780028b6cff77a9f25f75a24047ab5f3b50a4834.tar.bz2 |
mt_allocator.html: Add docs for _Tune.
2004-07-13 Benjamin Kosnik <bkoz@redhat.com>
* docs/html/ext/mt_allocator.html: Add docs for _Tune.
* include/ext/mt_allocator.h (__mt_alloc::_S_get_options): Make public.
(__mt_alloc::_S_set_options): Same.
Add to comments.
2004-07-13 Benjamin Kosnik <bkoz@redhat.com>
* acinclude.m4 (GLIBCXX_ENABLE_ALLOCATOR): Add allocator defaults
for linux.
* configure: Regenerated.
From-SVN: r84674
Diffstat (limited to 'libstdc++-v3/docs')
-rw-r--r-- | libstdc++-v3/docs/html/ext/mt_allocator.html | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/libstdc++-v3/docs/html/ext/mt_allocator.html b/libstdc++-v3/docs/html/ext/mt_allocator.html index 7272711..4fdee61 100644 --- a/libstdc++-v3/docs/html/ext/mt_allocator.html +++ b/libstdc++-v3/docs/html/ext/mt_allocator.html @@ -53,6 +53,61 @@ The aim of this document is to describe - from a application point of view - the "inner workings" of the allocator. </p> +<h3 class="left"> + <a name="init">Tunable parameters</a> +</h3> + +<p>Certain allocation parameters can be modified on a per-type +basis. There exists a nested <pre>struct _Tune</pre> that contains all +these parameters, which include settings for +</p> + <ul> + <li>Alignment </li> + <li>Maximum bytes before calling <code>::operator new</code> directly</li> + <li>Minimum bytes</li> + <li>Size of underlying global allocations</li> + <li>Maximum number of supported threads</li> + <li>Migration of deallocations to the global free list</li> + <li>Shunt for global <code>new</code> and <code>delete</code></li> + </ul> +<p>Adjusting parameters for a given instance of an allocator can only +happen before any allocations take place, when the allocator itself is +initialized. For instance: +</p> +<pre> +#include <ext/mt_allocator.h> + +struct pod +{ + int i; + int j; +}; + +int main() +{ + typedef pod value_type; + typedef __gnu_cxx::__mt_alloc<value_type> allocator_type; + typedef allocator_type::_Tune tune_type; + + tune_type t_default; + tune_type t_opt(16, 5120, 32, 5120, 20, 10, false); + tune_type t_single(16, 5120, 32, 5120, 1, 10, false); + + tune_type t; + t = allocator_type::_S_get_options(); + allocator_type::_S_set_options(t_opt); + t = allocator_type::_S_get_options(); + + allocator_type a; + allocator_type::pointer p1 = a.allocate(128); + allocator_type::pointer p2 = a.allocate(5128); + + a.deallocate(p1, 128); + a.deallocate(p2, 5128); + + return 0; +} +</pre> <h3 class="left"> <a name="init">Initialization</a> @@ -60,14 +115,9 @@ view - the "inner workings" of the allocator. <p> The static variables (pointers to freelists, tuning parameters etc) -are initialized to their default values at file scope, i.e.: +are initialized as above, or are set to the global defaults. </p> -<pre> - template<typename _Tp> size_t - __mt_alloc<_Tp>::_S_freelist_headroom = 10; -</pre> - <p> The very first allocate() call will always call the _S_init() function. In order to make sure that this function is called exactly once we make use |