ACE_Allocator_Adapter< MALLOC > 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< MALLOC >:

Inheritance graph
[legend]
Collaboration diagram for ACE_Allocator_Adapter< MALLOC >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef MALLOC ALLOCATOR
typedef const void * MEMORY_POOL_OPTIONS

Public Member Functions

 ACE_Allocator_Adapter (const char *pool_name=0)
 ACE_Allocator_Adapter (const char *pool_name, const char *lock_name, MEMORY_POOL_OPTIONS options=0)
virtual ~ACE_Allocator_Adapter (void)
 Destructor.
virtual void * malloc (size_t nbytes)
 Allocate nbytes, but don't give them any initial value.
virtual void * calloc (size_t nbytes, char initial_value= '\0')
 Allocate nbytes, giving them all an initial_value.
virtual void * calloc (size_t n_elem, size_t elem_size, char initial_value= '\0')
virtual void free (void *ptr)
 Free ptr (must have been allocated by ACE_Allocator::malloc()).
virtual int remove (void)
 Remove any resources associated with this memory manager.
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)
virtual int find (const char *name)
 Returns 0 if the name is in the mapping and -1 if not.
virtual int unbind (const char *name)
virtual int unbind (const char *name, void *&pointer)
virtual int sync (ssize_t len=-1, int flags=MS_SYNC)
virtual int sync (void *addr, size_t len, int flags=MS_SYNC)
virtual int protect (ssize_t len=-1, int prot=PROT_RDWR)
virtual int protect (void *addr, size_t len, int prot=PROT_RDWR)
ALLOCATORalloc (void)
 Returns the underlying allocator.
virtual void dump (void) const
 Dump the state of the object.

Private Attributes

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

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 211 of file Malloc_T.h.


Member Typedef Documentation

template<class MALLOC>
typedef MALLOC ACE_Allocator_Adapter< MALLOC >::ALLOCATOR

Definition at line 215 of file Malloc_T.h.

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

Definition at line 222 of file Malloc_T.h.


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 296 of file Malloc_T.cpp.

References ACE_TRACE.

00297   : allocator_ (ACE_TEXT_CHAR_TO_TCHAR (pool_name))
00298 {
00299   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::ACE_Allocator_Adapter");
00300 }

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 238 of file Malloc_T.h.

References ACE_TRACE.

00241       : allocator_ (ACE_TEXT_CHAR_TO_TCHAR (pool_name),
00242                     ACE_TEXT_CHAR_TO_TCHAR (lock_name),
00243                     options)
00244     {
00245       ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::ACE_Allocator_Adapter");
00246     }

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

Destructor.

Definition at line 312 of file Malloc_T.cpp.

References ACE_TRACE.

00313 {
00314   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::~ACE_Allocator_Adapter");
00315 }


Member Function Documentation

template<class MALLOC>
MALLOC & ACE_Allocator_Adapter< MALLOC >::alloc ( void   ) 

Returns the underlying allocator.

Definition at line 201 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

00202 {
00203   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::allocator");
00204   return this->allocator_;
00205 }

template<class MALLOC>
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 230 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

00233 {
00234   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::bind");
00235   return this->allocator_.bind (name, pointer, duplicates);
00236 }

template<class MALLOC>
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 192 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

00195 {
00196   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::calloc");
00197   return this->allocator_.calloc (n_elem, elem_size, initial_value);
00198 }

template<class MALLOC>
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 184 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

00186 {
00187   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::calloc");
00188   return this->allocator_.calloc (nbytes, initial_value);
00189 }

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

Dump the state of the object.

Implements ACE_Allocator.

Definition at line 327 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

00328 {
00329 #if defined (ACE_HAS_DUMP)
00330   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::dump");
00331   this->allocator_.dump ();
00332 #endif /* ACE_HAS_DUMP */
00333 }

template<class MALLOC>
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 247 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

00248 {
00249   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::find");
00250   return this->allocator_.find (name);
00251 }

template<class MALLOC>
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 239 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

00241 {
00242   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::find");
00243   return this->allocator_.find (name, pointer);
00244 }

template<class MALLOC>
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 208 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

Referenced by ACE_Local_Name_Space<, ACE_LOCK >::shared_bind_i(), and ACE_Local_Name_Space<, ACE_LOCK >::unbind_i().

00209 {
00210   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::free");
00211   this->allocator_.free (ptr);
00212 }

template<class MALLOC>
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 177 of file Malloc_T.cpp.

References ACE_TRACE.

Referenced by ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i().

00178 {
00179   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::malloc");
00180   return this->allocator_.malloc (nbytes);
00181 }

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 289 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

00290 {
00291   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::protect");
00292   return this->allocator_.protect (addr, len, flags);
00293 }

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 282 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

00283 {
00284   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::protect");
00285   return this->allocator_.protect (len, flags);
00286 }

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

Remove any resources associated with this memory manager.

Implements ACE_Allocator.

Definition at line 215 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

00216 {
00217   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::remove");
00218   return this->allocator_.remove ();
00219 }

template<class MALLOC>
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 275 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

00276 {
00277   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::sync");
00278   return this->allocator_.sync (addr, len, flags);
00279 }

template<class MALLOC>
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 268 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

Referenced by ACE_Local_Name_Space<, ACE_LOCK >::shared_bind_i().

00269 {
00270   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::sync");
00271   return this->allocator_.sync (len, flags);
00272 }

template<class MALLOC>
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 222 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

00224 {
00225   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::trybind");
00226   return this->allocator_.trybind (name, pointer);
00227 }

template<class MALLOC>
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 254 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

00255 {
00256   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::unbind");
00257   return this->allocator_.unbind (name, pointer);
00258 }

template<class MALLOC>
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 261 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Allocator_Adapter< MALLOC >::allocator_.

00262 {
00263   ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::unbind");
00264   return this->allocator_.unbind (name);
00265 }


Member Data Documentation

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

ALLOCATOR instance, which is owned by the adapter.

Reimplemented from ACE_Allocator.

Definition at line 372 of file Malloc_T.h.

Referenced by ACE_Allocator_Adapter< MALLOC >::alloc(), ACE_Allocator_Adapter< MALLOC >::bind(), ACE_Allocator_Adapter< MALLOC >::calloc(), ACE_Allocator_Adapter< MALLOC >::dump(), ACE_Allocator_Adapter< MALLOC >::find(), ACE_Allocator_Adapter< MALLOC >::free(), ACE_Allocator_Adapter< MALLOC >::protect(), ACE_Allocator_Adapter< MALLOC >::remove(), ACE_Allocator_Adapter< MALLOC >::sync(), ACE_Allocator_Adapter< MALLOC >::trybind(), and ACE_Allocator_Adapter< MALLOC >::unbind().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:34:54 2010 for ACE by  doxygen 1.4.7