# ace::MemoryPool< _Type, _Block > Class Template Reference

Definition of memory pool (abstract) interface. More...

`#include <pool.h>`

Inherited by ace::RandomSizedMemoryPool< _Type >, and ace::RandomSizedMemoryPool< char >.

List of all members.

## Public Member Functions
| MemoryPool (size_t block_size) throw ()
| Constructor accepts and stores block size, doesn't allocate any memory yet.
virtual | ~MemoryPool (void) throw ()
| Destructor does nothing useful, just is.
size_t | block_size (void) const throw ()
virtual void | clear (void)=0 throw ()
| Method used to clear the pool - should deallocate all dynamically allocated memory.
virtual _Type * | get_memory (size_t mem_size)=0
| Returns pointer to free memory of size `mem_size` or throws std::bad_alloc in case there is not enough free memory.
## Protected Member Functions
virtual _Block< _Type > * | create_new_block (void)=0
| Function for allocation of new memory blocks.
## Private Attributes
size_t | _block_size
| Block size.

## Detailed Description

### template<class _Type, template< typename _Type > class _Block>
class ace::MemoryPool< _Type, _Block >

Definition of memory pool (abstract) interface.

Doesn't do much, just define some basic behavior.

Parameters:

  | _Type | Stored unit type.
  | _Block | Pool memory block template class.

## Constructor & Destructor Documentation

template<class _Type, template< typename _Type > class _Block>

ace::MemoryPool< _Type, _Block >::MemoryPool | ( | size_t | block_size | ) | throw ()`[inline]`

Constructor accepts and stores block size, doesn't allocate any memory yet.

Parameters:

  | block_size | Size of memory blocks within the pool.

template<class _Type, template< typename _Type > class _Block>

virtual ace::MemoryPool< _Type, _Block >::~MemoryPool | ( | void |  | ) | throw ()`[inline, virtual]`

Destructor does nothing useful, just is.

## Member Function Documentation

template<class _Type, template< typename _Type > class _Block>

virtual _Block<_Type>* ace::MemoryPool< _Type, _Block >::create_new_block | ( | void |  | ) | `[protected, pure virtual]`

Function for allocation of new memory blocks.

Implemented in ace::RandomSizedMemoryPool< _Type >, and ace::RandomSizedMemoryPool< char >.

template<class _Type, template< typename _Type > class _Block>

size_t ace::MemoryPool< _Type, _Block >::block_size | ( | void |  | ) | const throw ()`[inline]`

Returns:
  Size of single memory block.

template<class _Type, template< typename _Type > class _Block>

virtual void ace::MemoryPool< _Type, _Block >::clear | ( | void |  | ) | throw ()`[pure virtual]`

Method used to clear the pool - should deallocate all dynamically allocated memory.

Implemented in ace::RandomSizedMemoryPool< _Type >, and ace::RandomSizedMemoryPool< char >.

template<class _Type, template< typename _Type > class _Block>

virtual _Type* ace::MemoryPool< _Type, _Block >::get_memory | ( | size_t | mem_size | ) | `[pure virtual]`

Returns pointer to free memory of size `mem_size` or throws std::bad_alloc in case there is not enough free memory.

Parameters:

  | mem_size | The size of demanded memory.

Returns:
  Pointer to beginning of the returned memory.

Exceptions:

  | std::bad_alloc | When there is no more memory available.

Implemented in ace::RandomSizedMemoryPool< _Type >, and ace::RandomSizedMemoryPool< char >.

## Member Data Documentation

template<class _Type, template< typename _Type > class _Block>

size_t ace::MemoryPool< _Type, _Block >::_block_size`[private]`

Block size.

The documentation for this class was generated from the following file:

- proto/Source/pool.h