NAME
ACE_Cached_Allocator - Create a cached memory poll with n_chunks chunks each with sizeof (TYPE) size.
SYNOPSIS
#include <ace/Malloc_T.h>
template<class T, class ACE_LOCK>
class ACE_Cached_Allocator : public ACE_New_Allocator
{
public:
ACE_Cached_Allocator (size_t n_chunks);
~ACE_Cached_Allocator (void);
void* malloc (size_t);
void free (void *);
private:
char *pool_;
ACE_Locked_Free_List<ACE_Cached_Mem_Pool_Node<T>, ACE_LOCK> free_list_;
};
DESCRIPTION
This class enables caching of dynamically allocated, fixed-sized classes.
PUBLIC MEMBERS
ACE_Cached_Allocator (size_t n_chunks);
Create a cached memory poll with n_chunks chunks each with sizeof (TYPE) size.
~ACE_Cached_Allocator (void);
clear things up.
void* malloc (size_t);
get a chunk of memory from free store.
void free (void *);
return a chunk of memory back to free store.
PRIVATE MEMBERS
char *pool_;
remember how we allocate the memory in the first place so we can clear things up later.
ACE_Locked_Free_List<ACE_Cached_Mem_Pool_Node<T>, ACE_LOCK> free_list_;
Maintain a cached memory free list.
AUTHOR
Doug Schmidt and Irfan Pyarali
LIBRARY
ace