Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Dynamic_Cached_Allocator Class Template Reference

Create a cached memory pool with <n_chunks> chunks each with requested size <chunk_size>. More...

#include <Malloc_T.h>

Inheritance diagram for ACE_Dynamic_Cached_Allocator:

Inheritance graph
[legend]
Collaboration diagram for ACE_Dynamic_Cached_Allocator:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Dynamic_Cached_Allocator (size_t n_chunks, size_t chunk_size)
 Create a cached memory pool with <n_chunks> chunks each with <chunk_size> size. More...

 ~ACE_Dynamic_Cached_Allocator (void)
 Clear things up. More...

void * malloc (size_t nbytes=0)
 Get a chunk of memory from free list cache. More...

virtual void * calloc (size_t nbytes, char initial_value='\0')
 Get a chunk of memory from free list cache, giving them <initial_value>. More...

virtual void * calloc (size_t n_elem, size_t elem_size, char initial_value='\0')
 This method is a no-op and just returns 0 since the free list only works with fixed sized entities. More...

void free (void *)
 Return a chunk of memory back to free list cache. More...


Private Attributes

char * pool_
 Remember how we allocate the memory in the first place so we can clear things up later. More...

ACE_Locked_Free_List< ACE_Cached_Mem_Pool_Node<
char >, ACE_LOCK > 
free_list_
 Maintain a cached memory free list. We use <char> as template parameter, although sizeof(char) is usually less than sizeof(void*). Really important is that <chunk_size> must be >= sizeof(void*). More...

size_t chunk_size_
 Remember the size of our chunks. More...


Detailed Description

template<class ACE_LOCK>
class ACE_Dynamic_Cached_Allocator< ACE_LOCK >

Create a cached memory pool with <n_chunks> chunks each with requested size <chunk_size>.

This class enables caching of dynamically allocated, chunks with size <chunk_size>. Notice that the chunk_size must be greater than or equal to sizeof (void*) for this to work properly.

See also:
ACE_Cached_Mem_Pool_Node


Constructor & Destructor Documentation

template<class ACE_LOCK>
ACE_Dynamic_Cached_Allocator< ACE_LOCK >::ACE_Dynamic_Cached_Allocator size_t    n_chunks,
size_t    chunk_size
 

Create a cached memory pool with <n_chunks> chunks each with <chunk_size> size.

template<class ACE_LOCK>
ACE_Dynamic_Cached_Allocator< ACE_LOCK >::~ACE_Dynamic_Cached_Allocator void   
 

Clear things up.


Member Function Documentation

template<class ACE_LOCK>
ACE_INLINE void * ACE_Dynamic_Cached_Allocator< ACE_LOCK >::calloc size_t    n_elem,
size_t    elem_size,
char    initial_value = '\0'
[virtual]
 

This method is a no-op and just returns 0 since the free list only works with fixed sized entities.

Reimplemented from ACE_New_Allocator.

template<class ACE_LOCK>
ACE_INLINE void * ACE_Dynamic_Cached_Allocator< ACE_LOCK >::calloc size_t    nbytes,
char    initial_value = '\0'
[virtual]
 

Get a chunk of memory from free list cache, giving them <initial_value>.

Note that <nbytes> is only checked to make sure that it's <= to <chunk_size>, and is otherwise ignored since <malloc> always returns a pointer to an item of <chunk_size>.

Reimplemented from ACE_New_Allocator.

template<class ACE_LOCK>
ACE_INLINE void ACE_Dynamic_Cached_Allocator< ACE_LOCK >::free void *    ptr [virtual]
 

Return a chunk of memory back to free list cache.

Reimplemented from ACE_New_Allocator.

template<class ACE_LOCK>
ACE_INLINE void * ACE_Dynamic_Cached_Allocator< ACE_LOCK >::malloc size_t    nbytes = 0 [virtual]
 

Get a chunk of memory from free list cache.

Note that <nbytes> is only checked to make sure that it's <= to <chunk_size>, and is otherwise ignored since <malloc> always returns a pointer to an item of <chunk_size> size.

Reimplemented from ACE_New_Allocator.


Member Data Documentation

template<class ACE_LOCK>
size_t ACE_Dynamic_Cached_Allocator::chunk_size_ [private]
 

Remember the size of our chunks.

template<class ACE_LOCK>
ACE_Locked_Free_List<ACE_Cached_Mem_Pool_Node<char>, ACE_LOCK> ACE_Dynamic_Cached_Allocator::free_list_ [private]
 

Maintain a cached memory free list. We use <char> as template parameter, although sizeof(char) is usually less than sizeof(void*). Really important is that <chunk_size> must be >= sizeof(void*).

template<class ACE_LOCK>
char* ACE_Dynamic_Cached_Allocator::pool_ [private]
 

Remember how we allocate the memory in the first place so we can clear things up later.


The documentation for this class was generated from the following files:
Generated on Thu May 23 00:17:06 2002 for ACE by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001