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

ACE_Allocator_Adapter Class Template Reference

This class is an Adapter that allows the ACE_Allocator to use the ACE_Malloc class below. More...

#include <Malloc_T.h>

Inheritance diagram for ACE_Allocator_Adapter:

Inheritance graph
[legend]
Collaboration diagram for ACE_Allocator_Adapter:

Collaboration graph
[legend]
List of all members.

Public Types

typedef MALLOC ALLOCATOR
typedef const ACE_TYPENAME
MALLOC::MEMORY_POOL_OPTIONS * 
MEMORY_POOL_OPTIONS

Public Methods

 ACE_Allocator_Adapter (const char *pool_name=0)
 ACE_Allocator_Adapter (const char *pool_name, const char *lock_name, MEMORY_POOL_OPTIONS options=0)
 ACE_Allocator_Adapter (const wchar_t *pool_name)
 ACE_Allocator_Adapter (const wchar_t *pool_name, const wchar_t *lock_name, MEMORY_POOL_OPTIONS options=0)
virtual ~ACE_Allocator_Adapter (void)
 Destructor. More...

virtual void * malloc (size_t nbytes)
 Allocate nbytes, but don't give them any initial value. More...

virtual void * calloc (size_t nbytes, char initial_value='\0')
 Allocate nbytes, giving them all an initial_value. More...

virtual void * calloc (size_t n_elem, size_t elem_size, char initial_value='\0')
 Allocate n_elem each of size elem_size, giving them initial_value. More...

virtual void free (void *ptr)
 Free ptr (must have been allocated by ACE_Allocator::malloc()). More...

virtual int remove (void)
 Remove any resources associated with this memory manager. More...

virtual int bind (const char *name, void *pointer, int duplicates=0)
virtual int trybind (const char *name, void *&pointer)
virtual int find (const char *name, void *&pointer)
 Locate name and pass out parameter via pointer. If found, return 0, returns -1 if name isn't found. More...

virtual int find (const char *name)
 Returns 0 if the name is in the mapping and -1 if not. More...

virtual int unbind (const char *name)
 Unbind (remove) the name from the map. Don't return the pointer to the caller. More...

virtual int unbind (const char *name, void *&pointer)
 Break any association of name. Returns the value of pointer in case the caller needs to deallocate memory. More...

virtual int sync (ssize_t len=-1, int flags=MS_SYNC)
virtual int sync (void *addr, size_t len, int flags=MS_SYNC)
 Sync len bytes of the memory region to the backing store starting at addr_. More...

virtual int protect (ssize_t len=-1, int prot=PROT_RDWR)
virtual int protect (void *addr, size_t len, int prot=PROT_RDWR)
 Change the protection of the pages of the mapped region to prot starting at addr up to len bytes. More...

ALLOCATORalloc (void)
 Returns the underlying allocator. More...

virtual void dump (void) const
 Dump the state of the object. More...


Private Attributes

ALLOCATOR allocator_
 ALLOCATOR instance, which is owned by the adapter. More...


Detailed Description

template<class MALLOC>
class ACE_Allocator_Adapter< MALLOC >

This class is an Adapter that allows the ACE_Allocator to use the ACE_Malloc class below.

Definition at line 194 of file Malloc_T.h.


Member Typedef Documentation

template<class MALLOC>
typedef MALLOC ACE_Allocator_Adapter::ALLOCATOR
 

Definition at line 198 of file Malloc_T.h.

template<class MALLOC>
typedef const ACE_TYPENAME MALLOC::MEMORY_POOL_OPTIONS* ACE_Allocator_Adapter::MEMORY_POOL_OPTIONS
 

Definition at line 203 of file Malloc_T.h.

Referenced by ACE_Allocator_Adapter< ACE_Malloc< ACE_MEM_POOL_2, ACE_LOCK > >::ACE_Allocator_Adapter.


Constructor & Destructor Documentation

template<class MALLOC>
ACE_Allocator_Adapter< MALLOC >::ACE_Allocator_Adapter const char *    pool_name = 0
 

Note that pool_name should be located in a directory with the appropriate visibility and protection so that all processes that need to access it can do so.

Definition at line 106 of file Malloc_T.cpp.

References ACE_TEXT_CHAR_TO_TCHAR, and ACE_TRACE.

00107   : allocator_ (ACE_TEXT_CHAR_TO_TCHAR (pool_name))
00108 {
00109   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::ACE_Allocator_Adapter");
00110 }

template<class MALLOC>
ACE_Allocator_Adapter< MALLOC >::ACE_Allocator_Adapter const char *    pool_name,
const char *    lock_name,
MEMORY_POOL_OPTIONS    options = 0
[inline]
 

Note that pool_name should be located in a directory with the appropriate visibility and protection so that all processes that need to access it can do so. This constructor must be inline to avoid bugs with some C++ compilers.

Definition at line 221 of file Malloc_T.h.

00224       : allocator_ (ACE_TEXT_CHAR_TO_TCHAR (pool_name),
00225                     ACE_TEXT_CHAR_TO_TCHAR (lock_name),
00226                     options)
00227     {
00228       ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::ACE_Allocator_Adapter");
00229     }

template<class MALLOC>
ACE_Allocator_Adapter< MALLOC >::ACE_Allocator_Adapter const wchar_t *    pool_name
 

Note that pool_name should be located in a directory with the appropriate visibility and protection so that all processes that need to access it can do so.

Definition at line 114 of file Malloc_T.cpp.

References ACE_TEXT_WCHAR_TO_TCHAR, and ACE_TRACE.

00115   : allocator_ (ACE_TEXT_WCHAR_TO_TCHAR (pool_name))
00116 {
00117   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::ACE_Allocator_Adapter");
00118 }

template<class MALLOC>
ACE_Allocator_Adapter< MALLOC >::ACE_Allocator_Adapter const wchar_t *    pool_name,
const wchar_t *    lock_name,
MEMORY_POOL_OPTIONS    options = 0
[inline]
 

Note that pool_name should be located in a directory with the appropriate visibility and protection so that all processes that need to access it can do so. This constructor must be inline to avoid bugs with some C++ compilers.

Definition at line 244 of file Malloc_T.h.

00247       : allocator_ (ACE_TEXT_WCHAR_TO_TCHAR (pool_name),
00248                     ACE_TEXT_WCHAR_TO_TCHAR (lock_name),
00249                     options)
00250     {
00251       ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::ACE_Allocator_Adapter");
00252     }

template<class MALLOC>
ACE_Allocator_Adapter< MALLOC >::~ACE_Allocator_Adapter void    [virtual]
 

Destructor.

Definition at line 122 of file Malloc_T.cpp.

References ACE_TRACE.

00123 {
00124   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::~ACE_Allocator_Adapter");
00125 }


Member Function Documentation

template<class MALLOC>
ACE_INLINE MALLOC & ACE_Allocator_Adapter< MALLOC >::alloc void   
 

Returns the underlying allocator.

Definition at line 133 of file Malloc_T.i.

References ACE_TRACE, and allocator_.

00134 {
00135   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::allocator");
00136   return this->allocator_;
00137 }

template<class MALLOC>
ACE_INLINE int ACE_Allocator_Adapter< MALLOC >::bind const char *    name,
void *    pointer,
int    duplicates = 0
[virtual]
 

Associate name with pointer. If duplicates == 0 then do not allow duplicate name/pointer associations, else if duplicates> != 0 then allow duplicate name/pointer assocations. Returns 0 if successfully binds (1) a previously unbound name or (2) duplicates != 0, returns 1 if trying to bind a previously bound name and duplicates == 0, else returns -1 if a resource failure occurs.

Implements ACE_Allocator.

Definition at line 162 of file Malloc_T.i.

References ACE_TRACE, and allocator_.

00165 {
00166   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::bind");
00167   return this->allocator_.bind (name, pointer, duplicates);
00168 }

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

Allocate n_elem each of size elem_size, giving them initial_value.

Implements ACE_Allocator.

Definition at line 124 of file Malloc_T.i.

References ACE_TRACE, and allocator_.

00127 {
00128   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::calloc");
00129   return this->allocator_.calloc (n_elem, elem_size, initial_value);
00130 }

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

Allocate nbytes, giving them all an initial_value.

Implements ACE_Allocator.

Definition at line 116 of file Malloc_T.i.

References ACE_TRACE, and allocator_.

00118 {
00119   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::calloc");
00120   return this->allocator_.calloc (nbytes, initial_value);
00121 }

template<class MALLOC>
void ACE_Allocator_Adapter< MALLOC >::dump void    const [virtual]
 

Dump the state of the object.

Implements ACE_Allocator.

Definition at line 137 of file Malloc_T.cpp.

References ACE_TRACE, and allocator_.

00138 {
00139   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::dump");
00140   this->allocator_.dump ();
00141 }

template<class MALLOC>
ACE_INLINE int ACE_Allocator_Adapter< MALLOC >::find const char *    name [virtual]
 

Returns 0 if the name is in the mapping and -1 if not.

Implements ACE_Allocator.

Definition at line 179 of file Malloc_T.i.

References ACE_TRACE, and allocator_.

00180 {
00181   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::find");
00182   return this->allocator_.find (name);
00183 }

template<class MALLOC>
ACE_INLINE int ACE_Allocator_Adapter< MALLOC >::find const char *    name,
void *&    pointer
[virtual]
 

Locate name and pass out parameter via pointer. If found, return 0, returns -1 if name isn't found.

Implements ACE_Allocator.

Definition at line 171 of file Malloc_T.i.

References ACE_TRACE, and allocator_.

Referenced by ACE_System_Time::get_master_system_time.

00173 {
00174   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::find");
00175   return this->allocator_.find (name, pointer);
00176 }

template<class MALLOC>
ACE_INLINE void ACE_Allocator_Adapter< MALLOC >::free void *    ptr [virtual]
 

Free ptr (must have been allocated by ACE_Allocator::malloc()).

Implements ACE_Allocator.

Definition at line 140 of file Malloc_T.i.

References ACE_TRACE, and allocator_.

00141 {
00142   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::free");
00143   this->allocator_.free (ptr);
00144 }

template<class MALLOC>
ACE_INLINE void * ACE_Allocator_Adapter< MALLOC >::malloc size_t    nbytes [virtual]
 

Allocate nbytes, but don't give them any initial value.

Implements ACE_Allocator.

Definition at line 109 of file Malloc_T.i.

References ACE_TRACE, and allocator_.

00110 {
00111   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::malloc");
00112   return this->allocator_.malloc (nbytes);
00113 }

template<class MALLOC>
int ACE_Allocator_Adapter< MALLOC >::protect void *    addr,
size_t    len,
int    prot = PROT_RDWR
[virtual]
 

Change the protection of the pages of the mapped region to prot starting at addr up to len bytes.

Implements ACE_Allocator.

Definition at line 99 of file Malloc_T.cpp.

References ACE_TRACE, and allocator_.

00100 {
00101   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::protect");
00102   return this->allocator_.protect (addr, len, flags);
00103 }

template<class MALLOC>
int ACE_Allocator_Adapter< MALLOC >::protect ssize_t    len = -1,
int    prot = PROT_RDWR
[virtual]
 

Change the protection of the pages of the mapped region to prot starting at this->base_addr_ up to len bytes. If len == -1 then change protection of all pages in the mapped region.

Implements ACE_Allocator.

Definition at line 92 of file Malloc_T.cpp.

References ACE_TRACE, allocator_, and ssize_t.

00093 {
00094   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::protect");
00095   return this->allocator_.protect (len, flags);
00096 }

template<class MALLOC>
ACE_INLINE int ACE_Allocator_Adapter< MALLOC >::remove void    [virtual]
 

Remove any resources associated with this memory manager.

Implements ACE_Allocator.

Definition at line 147 of file Malloc_T.i.

References ACE_TRACE, and allocator_.

00148 {
00149   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::remove");
00150   return this->allocator_.remove ();
00151 }

template<class MALLOC>
ACE_INLINE int ACE_Allocator_Adapter< MALLOC >::sync void *    addr,
size_t    len,
int    flags = MS_SYNC
[virtual]
 

Sync len bytes of the memory region to the backing store starting at addr_.

Implements ACE_Allocator.

Definition at line 207 of file Malloc_T.i.

References ACE_TRACE, and allocator_.

00208 {
00209   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::sync");
00210   return this->allocator_.sync (addr, len, flags);
00211 }

template<class MALLOC>
ACE_INLINE int ACE_Allocator_Adapter< MALLOC >::sync ssize_t    len = -1,
int    flags = MS_SYNC
[virtual]
 

Sync len bytes of the memory region to the backing store starting at this->base_addr_. If len == -1 then sync the whole region.

Implements ACE_Allocator.

Definition at line 200 of file Malloc_T.i.

References ACE_TRACE, allocator_, and ssize_t.

00201 {
00202   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::sync");
00203   return this->allocator_.sync (len, flags);
00204 }

template<class MALLOC>
ACE_INLINE int ACE_Allocator_Adapter< MALLOC >::trybind const char *    name,
void *&    pointer
[virtual]
 

Associate name with pointer. Does not allow duplicate name/pointer associations. Returns 0 if successfully binds (1) a previously unbound name, 1 if trying to bind a previously bound name, or returns -1 if a resource failure occurs. When this call returns, pointer's value will always reference the void * that name is associated with. Thus, if the caller needs to use pointer (e.g., to free it) a copy must be maintained by the caller.

Implements ACE_Allocator.

Definition at line 154 of file Malloc_T.i.

References ACE_TRACE, and allocator_.

00156 {
00157   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::trybind");
00158   return this->allocator_.trybind (name, pointer);
00159 }

template<class MALLOC>
ACE_INLINE int ACE_Allocator_Adapter< MALLOC >::unbind const char *    name,
void *&    pointer
[virtual]
 

Break any association of name. Returns the value of pointer in case the caller needs to deallocate memory.

Implements ACE_Allocator.

Definition at line 186 of file Malloc_T.i.

References ACE_TRACE, and allocator_.

00187 {
00188   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::unbind");
00189   return this->allocator_.unbind (name, pointer);
00190 }

template<class MALLOC>
ACE_INLINE int ACE_Allocator_Adapter< MALLOC >::unbind const char *    name [virtual]
 

Unbind (remove) the name from the map. Don't return the pointer to the caller.

Implements ACE_Allocator.

Definition at line 193 of file Malloc_T.i.

References ACE_TRACE, and allocator_.

00194 {
00195   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::unbind");
00196   return this->allocator_.unbind (name);
00197 }


Member Data Documentation

template<class MALLOC>
ALLOCATOR ACE_Allocator_Adapter::allocator_ [private]
 

ALLOCATOR instance, which is owned by the adapter.

Reimplemented from ACE_Allocator.

Definition at line 355 of file Malloc_T.h.

Referenced by ACE_Allocator_Adapter< ACE_Malloc< ACE_MEM_POOL_2, ACE_LOCK > >::ACE_Allocator_Adapter, alloc, bind, calloc, dump, find, free, malloc, protect, remove, sync, trybind, and unbind.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:44:52 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002