ace::ContinuousPool< _Type > Class Template Reference

ContinuousPool serves as memory pool of (virtually) unlimited size, which enables the caller to store objects of given size in one-by-one fashion (that is significant difference from RandomSizedMemoryPool). More...

#include <pool.h>

Inherits ace::MemoryPool< _Type, _Block >< _Type, ace::ContinuousMemoryBlock< _Type > >.

List of all members.

Public Member Functions

 ContinuousPool (size_t block_size) throw ()
 Constructor initializes the pool, but does not allocate any memory yet.
virtual ~ContinuousPool (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)
_Type * shift (const _Type *pointer, intptr_t offset) const throw ()
 Returns pointer to memory shifted by given offset (considered as stored units offset, not byte offset).
_Type * start (void) const throw ()

Protected Member Functions

virtual ContinuousMemoryBlock
< _Type > * 
create_new_block (void)
 Creates new memory block.

Private Types

typedef std::map< _Type
*, ContinuousMemoryBlock
< _Type > * > 
_blocks_end_bounds_map
 Type defining mapping memory block upper_bound to block itself (pointer to).

Private Attributes

_blocks_end_bounds_map _mem_blocks
 Maps blocks upper bound values (addresses) to blocks themself.
ContinuousMemoryBlock< _Type > * _first
 First pool block.
ContinuousMemoryBlock< _Type > * _recent
 Recent pool block (the last one).


Detailed Description

template<class _Type>
class ace::ContinuousPool< _Type >

ContinuousPool serves as memory pool of (virtually) unlimited size, which enables the caller to store objects of given size in one-by-one fashion (that is significant difference from RandomSizedMemoryPool).

Due to this approach it's possible to shift between objects of same pool (see shift()).

Parameters:
_Type Type to be stored within the block.
See also:
ContinuousMemoryBlock

Definition at line 383 of file pool.h.


Constructor & Destructor Documentation

template<class _Type>
ace::ContinuousPool< _Type >::ContinuousPool ( size_t  block_size  )  throw () [inline]

Constructor initializes the pool, but does not allocate any memory yet.

Parameters:
block_size Size of memory blocks within the pool.

Definition at line 415 of file pool.h.


Member Function Documentation

template<class _Type>
virtual ContinuousMemoryBlock<_Type>* ace::ContinuousPool< _Type >::create_new_block ( void   )  [inline, protected, virtual]

Creates new memory block.

Returns:
Pointer to newly created memory pool block.
Exceptions:
std::bad_alloc when there is not enough memory left to allocate new pool block.

Implements ace::MemoryPool< _Type, _Block >.

Definition at line 402 of file pool.h.

template<class _Type>
virtual void ace::ContinuousPool< _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 >.

Definition at line 424 of file pool.h.

template<class _Type>
virtual _Type* ace::ContinuousPool< _Type >::get_memory ( size_t   )  [inline, virtual]

Returns:
Pointer to the next slot of free memory.
Exceptions:
std::bad_alloc When there is no more memory available.

Implements ace::MemoryPool< _Type, _Block >.

Definition at line 433 of file pool.h.

template<class _Type>
_Type* ace::ContinuousPool< _Type >::shift ( const _Type *  pointer,
intptr_t  offset 
) const throw () [inline]

Returns pointer to memory shifted by given offset (considered as stored units offset, not byte offset).

Note that: 1. Pointer must point somewhere into the "continuous memory" (call with invalid pointer is rejected even if after shifting the pointer will point to valid memory), otherwise NULL is returned. 2. If offset shifts the pointer behind the "continuous memory", NULL is returned.

Parameters:
pointer Pointer to the "continuous memory" from which apply the offset.
offset Shift offset (in stored units).
Returns:
Pointer to "continuous memory" shifted by given offset or NULL, if params were invalid.

Definition at line 456 of file pool.h.

template<class _Type>
_Type* ace::ContinuousPool< _Type >::start ( void   )  const throw () [inline]

Returns:
Pointer to the start of "continuous memory" or NULL, if there is no assigned memory yet (get_memory() hasn't been called yet).

Definition at line 470 of file pool.h.


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

Generated on Mon May 5 00:50:54 2008 for ACE by  doxygen 1.5.5