ACE_Cached_Allocator< T, ACE_LOCK > Class Template ReferenceA fixed-size allocator that caches items for quicker access. More...
Inheritance diagram for ACE_Cached_Allocator< T, ACE_LOCK >:
![]()
Collaboration diagram for ACE_Cached_Allocator< T, ACE_LOCK >:
![]()
Detailed Descriptiontemplate<class T, class ACE_LOCK>
A fixed-size allocator that caches items for quicker access.
|
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Cached_Allocator< T, ACE_LOCK >::ACE_Cached_Allocator | ( | size_t | n_chunks | ) | [inline] |
Create a cached memory pool with n_chunks chunks each with sizeof (TYPE) size.
ACE_Cached_Allocator< T, ACE_LOCK >::~ACE_Cached_Allocator | ( | void | ) | [inline] |
Clear things up.
void * ACE_Cached_Allocator< T, ACE_LOCK >::malloc | ( | size_t | nbytes = sizeof (T) |
) | [inline, virtual] |
Get a chunk of memory from free list cache. Note that nbytes is only checked to make sure that it's less or equal to sizeof T, and is otherwise ignored since malloc()
always returns a pointer to an item of sizeof (T).
Reimplemented from ACE_New_Allocator.
void * ACE_Cached_Allocator< T, ACE_LOCK >::calloc | ( | size_t | nbytes, | |
char | initial_value = '\0' | |||
) | [inline, 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 less or equal to sizeof T, and is otherwise ignored since calloc() always returns a pointer to an item of sizeof (T).
Reimplemented from ACE_New_Allocator.
void * ACE_Cached_Allocator< T, ACE_LOCK >::calloc | ( | size_t | n_elem, | |
size_t | elem_size, | |||
char | initial_value = '\0' | |||
) | [inline, 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.
void ACE_Cached_Allocator< T, ACE_LOCK >::free | ( | void * | ptr | ) | [inline, virtual] |
ACE_INLINE size_t ACE_Cached_Allocator< T, ACE_LOCK >::pool_depth | ( | void | ) | [inline] |
Return the number of chunks available in the cache.
char* ACE_Cached_Allocator< T, ACE_LOCK >::pool_ [private] |
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> ACE_Cached_Allocator< T, ACE_LOCK >::free_list_ [private] |
Maintain a cached memory free list.