OpenDDS::DCPS::FirstTimeFastAllocator< T, N > Class Template Reference

#include <ZeroCopyAllocator_T.h>

Inheritance diagram for OpenDDS::DCPS::FirstTimeFastAllocator< T, N >:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::FirstTimeFastAllocator< T, N >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FirstTimeFastAllocator ()
virtual void * malloc (size_t nbytes)
virtual void free (void *ptr)
virtual void * calloc (size_t nbytes, char initial_value= '\0')
 These methods are no-ops.
virtual void * calloc (size_t n_elem, size_t elem_size, char initial_value= '\0')
virtual int remove ()
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)
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)
virtual void dump () const
T * pool ()

Private Attributes

bool firstTime_
 is this the first time this is allocated?
pool_ [N]
 the pool of allocated memory.

Detailed Description

template<class T, std::size_t N>
class OpenDDS::DCPS::FirstTimeFastAllocator< T, N >

This allocator is "Fast" because it's pool can be on the stack (If the object is on the stack and hence it does not require the cost of allocating and deallocating on the heap. It object is on the heap then it requires just one allocation; not two.) WARNING* The object using this allocator must not have a scope smaller than this object !!!

Definition at line 32 of file ZeroCopyAllocator_T.h.


Constructor & Destructor Documentation

template<class T , std::size_t N>
ACE_INLINE OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::FirstTimeFastAllocator (  )  [inline]

Definition at line 14 of file ZeroCopyAllocator_T.inl.

00015   : firstTime_(true)
00016   , pool_()
00017 {
00018 }


Member Function Documentation

template<class T , std::size_t N>
int OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::bind ( const char *  name,
void *  pointer,
int  duplicates = 0 
) [inline, virtual]

Implements ACE_Allocator.

Definition at line 59 of file ZeroCopyAllocator_T.cpp.

References ACE_TEXT(), and LM_ERROR.

00060 {/* no-op */
00061   ACE_ERROR((LM_ERROR,
00062              ACE_TEXT("(%P|%t) %T not supported %a\n"))) ;
00063   ACE_UNUSED_ARG(name);
00064   ACE_UNUSED_ARG(pointer);
00065   ACE_UNUSED_ARG(duplicates);
00066   return -1;
00067 }

Here is the call graph for this function:

template<class T , std::size_t N>
void * OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::calloc ( size_t  n_elem,
size_t  elem_size,
char  initial_value = '\0' 
) [inline, virtual]

Definition at line 40 of file ZeroCopyAllocator_T.cpp.

00041 {/* no-op */
00042   ACE_UNUSED_ARG(n_elem);
00043   ACE_UNUSED_ARG(elem_size);
00044   ACE_UNUSED_ARG(initial_value);
00045   return (void*)0;
00046 }

template<class T , std::size_t N>
void * OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::calloc ( size_t  nbytes,
char  initial_value = '\0' 
) [inline, virtual]

These methods are no-ops.

Definition at line 31 of file ZeroCopyAllocator_T.cpp.

00032 {/* no-op */
00033   ACE_UNUSED_ARG(nbytes);
00034   ACE_UNUSED_ARG(initial_value);
00035   return (void*)0;
00036 }

template<class T , std::size_t N>
void OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::dump ( void   )  const [inline, virtual]

Implements ACE_Allocator.

Definition at line 181 of file ZeroCopyAllocator_T.cpp.

References ACE_TEXT(), and LM_ERROR.

00182 {/* no-op */
00183   ACE_ERROR((LM_ERROR,
00184              ACE_TEXT("(%P|%t) %T not supported %a\n"))) ;
00185 }

Here is the call graph for this function:

template<class T , std::size_t N>
int OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::find ( const char *  name  )  [inline, virtual]

Implements ACE_Allocator.

Definition at line 93 of file ZeroCopyAllocator_T.cpp.

References ACE_TEXT(), and LM_ERROR.

00094 {/* no-op */
00095   ACE_ERROR((LM_ERROR,
00096              ACE_TEXT("(%P|%t) %T not supported %a\n"))) ;
00097   ACE_UNUSED_ARG(name);
00098   return -1;
00099 }

Here is the call graph for this function:

template<class T , std::size_t N>
int OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::find ( const char *  name,
void *&  pointer 
) [inline, virtual]

Implements ACE_Allocator.

Definition at line 82 of file ZeroCopyAllocator_T.cpp.

References ACE_TEXT(), and LM_ERROR.

00083 {/* no-op */
00084   ACE_ERROR((LM_ERROR,
00085              ACE_TEXT("(%P|%t) %T not supported %a\n"))) ;
00086   ACE_UNUSED_ARG(name);
00087   ACE_UNUSED_ARG(pointer);
00088   return -1;
00089 }

Here is the call graph for this function:

template<class T , std::size_t N>
ACE_INLINE void OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::free ( void *  ptr  )  [inline, virtual]

Implements ACE_Allocator.

Definition at line 39 of file ZeroCopyAllocator_T.inl.

References ACE_Allocator::free(), ACE_Allocator::instance(), and OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::pool_.

00040 {
00041   if (ptr != (void*) pool_) {
00042 #if defined (ACE_HAS_ALLOC_HOOKS)
00043      ACE_Allocator::instance()->free(ptr);
00044 #else
00045     ACE_OS::free(ptr);
00046 #endif /* ACE_HAS_ALLOC_HOOKS */
00047   }
00048 }

Here is the call graph for this function:

template<class T , std::size_t N>
ACE_INLINE void * OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::malloc ( size_t  nbytes  )  [inline, virtual]

Definition at line 22 of file ZeroCopyAllocator_T.inl.

References OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::firstTime_, ACE_Allocator::instance(), ACE_Allocator::malloc(), and OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::pool_.

00023 {
00024   if (firstTime_ && nbytes <= N * sizeof(T)) {
00025     firstTime_ = false;
00026     return (void*) pool_;
00027 
00028   } else {
00029 #if defined (ACE_HAS_ALLOC_HOOKS)
00030     return ACE_Allocator::instance()->malloc(nbytes);
00031 #else
00032     return ACE_OS::malloc(nbytes);
00033 #endif /* ACE_HAS_ALLOC_HOOKS */
00034   }
00035 }

Here is the call graph for this function:

template<class T, std::size_t N>
T* OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::pool ( void   )  [inline]

Definition at line 57 of file ZeroCopyAllocator_T.h.

Referenced by TAO::DCPS::ZeroCopyDataSeq< Sample_T, DEF_MAX >::swap().

00057             {
00058     return pool_;
00059   }

Here is the caller graph for this function:

template<class T , std::size_t N>
int OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::protect ( void *  addr,
size_t  len,
int  prot = PROT_RDWR 
) [inline, virtual]

Definition at line 158 of file ZeroCopyAllocator_T.cpp.

References ACE_TEXT(), and LM_ERROR.

00159 {/* no-op */
00160   ACE_ERROR((LM_ERROR,
00161              ACE_TEXT("(%P|%t) %T not supported %a\n"))) ;
00162   ACE_UNUSED_ARG(addr);
00163   ACE_UNUSED_ARG(len);
00164   ACE_UNUSED_ARG(prot);
00165   return -1;
00166 }

Here is the call graph for this function:

template<class T , std::size_t N>
int OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::protect ( ssize_t  len = -1,
int  prot = PROT_RDWR 
) [inline, virtual]

Implements ACE_Allocator.

Definition at line 147 of file ZeroCopyAllocator_T.cpp.

References ACE_TEXT(), and LM_ERROR.

00148 {/* no-op */
00149   ACE_ERROR((LM_ERROR,
00150              ACE_TEXT("(%P|%t) %T not supported %a\n"))) ;
00151   ACE_UNUSED_ARG(len);
00152   ACE_UNUSED_ARG(prot);
00153   return -1;
00154 }

Here is the call graph for this function:

template<class T , std::size_t N>
int OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::remove ( void   )  [inline, virtual]

Implements ACE_Allocator.

Definition at line 50 of file ZeroCopyAllocator_T.cpp.

References ACE_TEXT(), and LM_ERROR.

00051 {/* no-op */
00052   ACE_ERROR((LM_ERROR,
00053              ACE_TEXT("(%P|%t) %T not supported %a\n"))) ;
00054   return -1;
00055 }

Here is the call graph for this function:

template<class T , std::size_t N>
int OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::sync ( void *  addr,
size_t  len,
int  flags = MS_SYNC 
) [inline, virtual]

Definition at line 135 of file ZeroCopyAllocator_T.cpp.

References ACE_TEXT(), and LM_ERROR.

00136 {/* no-op */
00137   ACE_ERROR((LM_ERROR,
00138              ACE_TEXT("(%P|%t) %T not supported %a\n"))) ;
00139   ACE_UNUSED_ARG(addr);
00140   ACE_UNUSED_ARG(len);
00141   ACE_UNUSED_ARG(flags);
00142   return -1;
00143 }

Here is the call graph for this function:

template<class T , std::size_t N>
int OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::sync ( ssize_t  len = -1,
int  flags = MS_SYNC 
) [inline, virtual]

Implements ACE_Allocator.

Definition at line 124 of file ZeroCopyAllocator_T.cpp.

References ACE_TEXT(), and LM_ERROR.

00125 {/* no-op */
00126   ACE_ERROR((LM_ERROR,
00127              ACE_TEXT("(%P|%t) %T not supported %a\n"))) ;
00128   ACE_UNUSED_ARG(len);
00129   ACE_UNUSED_ARG(flags);
00130   return -1;
00131 }

Here is the call graph for this function:

template<class T , std::size_t N>
int OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::trybind ( const char *  name,
void *&  pointer 
) [inline, virtual]

Implements ACE_Allocator.

Definition at line 71 of file ZeroCopyAllocator_T.cpp.

References ACE_TEXT(), and LM_ERROR.

00072 {/* no-op */
00073   ACE_ERROR((LM_ERROR,
00074              ACE_TEXT("(%P|%t) %T not supported %a\n"))) ;
00075   ACE_UNUSED_ARG(name);
00076   ACE_UNUSED_ARG(pointer);
00077   return -1;
00078 }

Here is the call graph for this function:

template<class T , std::size_t N>
int OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::unbind ( const char *  name,
void *&  pointer 
) [inline, virtual]

Implements ACE_Allocator.

Definition at line 113 of file ZeroCopyAllocator_T.cpp.

References ACE_TEXT(), and LM_ERROR.

00114 {/* no-op */
00115   ACE_ERROR((LM_ERROR,
00116              ACE_TEXT("(%P|%t) %T not supported %a\n"))) ;
00117   ACE_UNUSED_ARG(name);
00118   ACE_UNUSED_ARG(pointer);
00119   return -1;
00120 }

Here is the call graph for this function:

template<class T , std::size_t N>
int OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::unbind ( const char *  name  )  [inline, virtual]

Implements ACE_Allocator.

Definition at line 103 of file ZeroCopyAllocator_T.cpp.

References ACE_TEXT(), and LM_ERROR.

00104 {/* no-op */
00105   ACE_ERROR((LM_ERROR,
00106              ACE_TEXT("(%P|%t) %T not supported %a\n"))) ;
00107   ACE_UNUSED_ARG(name);
00108   return -1;
00109 }

Here is the call graph for this function:


Member Data Documentation

template<class T, std::size_t N>
bool OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::firstTime_ [private]

is this the first time this is allocated?

Definition at line 63 of file ZeroCopyAllocator_T.h.

Referenced by OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::malloc().

template<class T, std::size_t N>
T OpenDDS::DCPS::FirstTimeFastAllocator< T, N >::pool_[N] [private]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1