#include <pool.h>
Inherits ace::MemoryPool< _Type, ace::MemoryBlock< _Type > >.
Public Member Functions | |
| RandomSizedMemoryPool (size_t block_size) throw () | |
| Constructor initializes new pool, but does not allocate any memory. | |
| virtual | ~RandomSizedMemoryPool (void) throw () |
| Destructor frees all allocated memory by calling clear(). | |
| virtual void | clear (void) throw () |
| Frees all the allocated memory (deletes all memory pool blocks). | |
| virtual _Type * | get_memory (size_t mem_size) |
| Returns pointer to free memory of size `mem_size`. | |
Protected Types | |
| typedef MemoryBlock< _Type > | _block_type |
| typedef std::multimap< size_t, _block_type * > | _blocks_free_sizes_map |
| Type used to keep info about remaining (available) memory in all existing pool blocks, except the one recently used (see below). | |
Protected Member Functions | |
| virtual _block_type * | create_new_block (void) |
| Creates new memory block. | |
Protected Attributes | |
| _block_type * | _recently_used_block |
| Pool block recently used for allocation. | |
| _blocks_free_sizes_map | _mem_blocks |
| Mapping from size of available free memory in certain block to the pointer to its instance. | |
It's perfectly useful to stored random-sized strings (as char sequences). Note that class is derived from MemoryPool template class with given type and MemoryBlock as particular type of block to be used.
| _Type | Stored unit type. |
typedef MemoryBlock<_Type> ace::RandomSizedMemoryPool< _Type >::_block_type [protected] |
typedef std::multimap<size_t, _block_type *> ace::RandomSizedMemoryPool< _Type >::_blocks_free_sizes_map [protected] |
Type used to keep info about remaining (available) memory in all existing pool blocks, except the one recently used (see below).
| ace::RandomSizedMemoryPool< _Type >::RandomSizedMemoryPool | ( | size_t | block_size | ) | throw () [inline] |
Constructor initializes new pool, but does not allocate any memory.
| block_size | Size of memory blocks within the pool. |
| virtual ace::RandomSizedMemoryPool< _Type >::~RandomSizedMemoryPool | ( | void | ) | throw () [inline, virtual] |
Destructor frees all allocated memory by calling clear().
| virtual _block_type* ace::RandomSizedMemoryPool< _Type >::create_new_block | ( | void | ) | [inline, protected, virtual] |
Creates new memory block.
| std::bad_alloc | when there is not enough memory left to allocate new pool block. |
Implements ace::MemoryPool< _Type, _Block >.
| virtual void ace::RandomSizedMemoryPool< _Type >::clear | ( | void | ) | throw () [inline, virtual] |
Frees all the allocated memory (deletes all memory pool blocks).
Use only when there is a guaranty that there are no pointers pointing at the memory pool left.
Implements ace::MemoryPool< _Type, _Block >.
| virtual _Type* ace::RandomSizedMemoryPool< _Type >::get_memory | ( | size_t | mem_size | ) | [inline, virtual] |
Returns pointer to free memory of size `mem_size`.
If `mem_size` is bigger than size of memory blocks within the pool, NULL is returned. Moreover if there is not enough memory and new memory cannot be allocated, function throws std::bad_alloc. there is not enough free memory.
| mem_size | The size of demanded memory. |
| std::bad_alloc | When there is no more memory available. |
Implements ace::MemoryPool< _Type, _Block >.
_block_type* ace::RandomSizedMemoryPool< _Type >::_recently_used_block [protected] |
Pool block recently used for allocation.
_blocks_free_sizes_map ace::RandomSizedMemoryPool< _Type >::_mem_blocks [protected] |
Mapping from size of available free memory in certain block to the pointer to its instance.
1.5.6