#include <pool_allocator.h>
Onikiri::pool_body< T >のコラボレーション図
Public 型 | |
typedef const value_type * | const_pointer |
typedef const value_type & | const_reference |
typedef ptrdiff_t | difference_type |
typedef value_type * | pointer |
typedef value_type & | reference |
typedef size_t | size_type |
typedef T | value_type |
Public メソッド | |
INLINE pointer | allocate (size_type count, const void *hint=0) |
INLINE void | deallocate (pointer ptr, size_type count) |
pool_body () | |
~pool_body () | |
Protected 型 | |
typedef pool_stack< T * > | stack_type |
Protected メソッド | |
void | allocate_chank (size_type count, stack_type *stack) |
Protected 変数 | |
std::vector< T * > | ptr_list |
std::vector< stack_type * > | ptr_stack_array |
構成 | |
class | pool_stack |
pool_allocator.h の 50 行で定義されています。
typedef const value_type* Onikiri::pool_body< T >::const_pointer |
pool_allocator.h の 56 行で定義されています。
typedef const value_type& Onikiri::pool_body< T >::const_reference |
pool_allocator.h の 57 行で定義されています。
typedef ptrdiff_t Onikiri::pool_body< T >::difference_type |
pool_allocator.h の 59 行で定義されています。
typedef value_type* Onikiri::pool_body< T >::pointer |
pool_allocator.h の 54 行で定義されています。
typedef value_type& Onikiri::pool_body< T >::reference |
pool_allocator.h の 55 行で定義されています。
typedef size_t Onikiri::pool_body< T >::size_type |
pool_allocator.h の 58 行で定義されています。
typedef pool_stack<T*> Onikiri::pool_body< T >::stack_type [protected] |
pool_allocator.h の 103 行で定義されています。
typedef T Onikiri::pool_body< T >::value_type |
pool_allocator.h の 53 行で定義されています。
Onikiri::pool_body< T >::pool_body | ( | ) | [inline] |
Onikiri::pool_body< T >::~pool_body | ( | ) | [inline] |
pool_allocator.h の 146 行で定義されています。
参照先 name・Onikiri::pool_body< T >::ptr_list・Onikiri::pool_body< T >::ptr_stack_array.
00147 { 00148 for(size_t i = 0; i < ptr_list.size(); i++){ 00149 ::operator delete( (void*)ptr_list[i] ); 00150 } 00151 for(size_t i = 0; i < ptr_stack_array.size(); i++){ 00152 if(ptr_stack_array[i]){ 00153 delete ptr_stack_array[i]; 00154 } 00155 } 00156 #ifdef ONIKIRI_POOL_ALLOCATOR_INVESTIGATE 00157 printf( "pool_allocator< %s > : \n\ttype size : %d bytes\n\ttotal : %d bytes, %d elements\n", typeid(T).name(), (int)sizeof(T), (int)total_memory, (int)total_count ); 00158 for( size_t i = 0; i < total_memory_array.size(); i++ ){ 00159 if( total_memory_array[i] > 0) 00160 printf("\t%d : %d bytes, %d elements\n", (int)i, (int)total_memory_array[i], (int)total_count_array[i] ); 00161 } 00162 #endif 00163 };
INLINE pointer Onikiri::pool_body< T >::allocate | ( | size_type | count, | |
const void * | hint = 0 | |||
) | [inline] |
pool_allocator.h の 165 行で定義されています。
参照先 Onikiri::pool_body< T >::allocate_chank()・Onikiri::pool_body< T >::pool_stack< U >::pop()・Onikiri::pool_body< T >::ptr_stack_array・Onikiri::pool_body< T >::pool_stack< U >::size()・Onikiri::pool_body< T >::pool_stack< U >::top().
参照元 Onikiri::pool_allocator< T >::allocate().
00168 { 00169 if(count == 0) 00170 return 0; 00171 00172 if(ptr_stack_array.size() <= count){ 00173 ptr_stack_array.resize(count+1, 0); 00174 } 00175 00176 stack_type* stack = ptr_stack_array[count]; 00177 if(stack == 0){ 00178 // Throw std::bad_alloc if memory allocation failed. 00179 stack = new stack_type(); 00180 ptr_stack_array[count] = stack; 00181 } 00182 00183 // Allocate memory chunk 00184 if(stack->size() == 0){ 00185 allocate_chank( count, stack ); 00186 } 00187 00188 pointer ptr = stack->top(); 00189 stack->pop(); 00190 return ptr; 00191 }
関数の呼び出しグラフ:
Here is the caller graph for this function:
void Onikiri::pool_body< T >::allocate_chank | ( | size_type | count, | |
stack_type * | stack | |||
) | [inline, protected] |
pool_allocator.h の 113 行で定義されています。
参照先 Onikiri::pool_body< T >::ptr_list・Onikiri::pool_body< T >::pool_stack< U >::push().
参照元 Onikiri::pool_body< T >::allocate().
00114 { 00115 size_t chunk_size = POOL_ALLOCATOR_CHUNK_SIZE_BASE / count; 00116 if(chunk_size < 4) 00117 chunk_size = 4; 00118 00119 // Throw std::bad_alloc if memory allocation failed. 00120 pointer chunk = (pointer)( ::operator new(chunk_size * count * sizeof(T)) ); 00121 ptr_list.push_back(chunk); 00122 00123 for( size_t i = 0; i < chunk_size; i++){ 00124 stack->push( chunk ); 00125 chunk += count; 00126 } 00127 00128 #ifdef ONIKIRI_POOL_ALLOCATOR_INVESTIGATE 00129 total_memory += chunk_size * count * sizeof(T); 00130 total_count += chunk_size * count; 00131 if( total_memory_array.size() <= count ){ 00132 total_memory_array.resize( count + 1 ); 00133 total_count_array.resize( count + 1 ); 00134 } 00135 total_memory_array[count] += chunk_size * count * sizeof(T); 00136 total_count_array[count] += chunk_size * count; 00137 #endif 00138 }
関数の呼び出しグラフ:
Here is the caller graph for this function:
INLINE void Onikiri::pool_body< T >::deallocate | ( | pointer | ptr, | |
size_type | count | |||
) | [inline] |
pool_allocator.h の 193 行で定義されています。
参照先 Onikiri::pool_body< T >::ptr_stack_array・Onikiri::pool_body< T >::pool_stack< U >::push().
参照元 Onikiri::pool_allocator< T >::deallocate().
00194 { 00195 stack_type* stack = ptr_stack_array[count]; 00196 stack->push(ptr); 00197 }
関数の呼び出しグラフ:
Here is the caller graph for this function:
std::vector<T*> Onikiri::pool_body< T >::ptr_list [protected] |
std::vector< stack_type* > Onikiri::pool_body< T >::ptr_stack_array [protected] |