Malloc_T.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Malloc_T.inl,v 4.5 2006/04/19 11:51:53 jwillemsen Exp
00004 
00005 #include "ace/OS_NS_string.h"
00006 
00007 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00008 
00009 template <class T> ACE_INLINE T *
00010 ACE_Cached_Mem_Pool_Node<T>::addr (void)
00011 {
00012   // This should be done using a single reinterpret_cast, but Sun/CC
00013   // (4.2) gets awfully confused when T is a char[20] (and maybe other
00014   // types).
00015   return static_cast<T *> (static_cast <void *> (this));
00016 }
00017 
00018 template <class T> ACE_INLINE ACE_Cached_Mem_Pool_Node<T> *
00019 ACE_Cached_Mem_Pool_Node<T>::get_next (void)
00020 {
00021   return this->next_;
00022 }
00023 
00024 template <class T> ACE_INLINE void
00025 ACE_Cached_Mem_Pool_Node<T>::set_next (ACE_Cached_Mem_Pool_Node<T> *ptr)
00026 {
00027   this->next_ = ptr;
00028 }
00029 
00030 template <class T, class ACE_LOCK> ACE_INLINE size_t
00031 ACE_Cached_Allocator<T, ACE_LOCK>::pool_depth (void)
00032 {
00033   return this->free_list_.size ();
00034 }
00035 
00036 template <class ACE_LOCK> ACE_INLINE size_t
00037 ACE_Dynamic_Cached_Allocator<ACE_LOCK>::pool_depth (void)
00038 {
00039   return this->free_list_.size ();
00040 }
00041 
00042 template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> ACE_INLINE int
00043 ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ref_counter (void)
00044 {
00045   ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
00046   if (this->cb_ptr_ != 0)
00047     return this->cb_ptr_->ref_counter_;
00048 
00049   return -1;
00050 }
00051 
00052 template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> ACE_INLINE int
00053 ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::bad (void)
00054 {
00055   return this->bad_flag_;
00056 }
00057 
00058 template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> ACE_INLINE int
00059 ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::release (int close)
00060 {
00061   ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *this->lock_, -1);
00062   if (this->cb_ptr_ != 0)
00063     {
00064       int const retv = --this->cb_ptr_->ref_counter_;
00065 
00066 #if 0
00067       ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("(%P) ACE_Malloc_T::release ->%d\n"),
00068                  this->cb_ptr_->ref_counter_ - 1));
00069 #endif /* 0 */
00070       if (close)
00071         this->memory_pool_.release (0);
00072 
00073       if (retv == 0)
00074         this->remove ();
00075       return retv;
00076     }
00077   return -1;
00078 }
00079 
00080 template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> ACE_INLINE ACE_MEM_POOL &
00081 ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::memory_pool (void)
00082 {
00083   ACE_TRACE ("ACE_Malloc_T<MEMORY_POOL, ACE_LOCK, ACE_CB>::memory_pool");
00084   return this->memory_pool_;
00085 }
00086 
00087 template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> ACE_INLINE int
00088 ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::sync (ssize_t len,
00089                                                     int flags)
00090 {
00091   ACE_TRACE ("ACE_Malloc_T<MEMORY_POOL, ACE_LOCK, ACE_CB>::sync");
00092   return this->memory_pool_.sync (len, flags);
00093 }
00094 
00095 template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> ACE_INLINE int
00096 ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::sync (void *addr,
00097                                                     size_t len,
00098                                                     int flags)
00099 {
00100   ACE_TRACE ("ACE_Malloc_T<MEMORY_POOL, ACE_LOCK, ACE_CB>::sync");
00101   return this->memory_pool_.sync (addr, len, flags);
00102 }
00103 
00104 template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> ACE_INLINE int
00105 ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::protect (ssize_t len,
00106                                                        int flags)
00107 {
00108   ACE_TRACE ("ACE_Malloc_T<MEMORY_POOL, ACE_LOCK, ACE_CB>::protect");
00109   return this->memory_pool_.protect (len, flags);
00110 }
00111 
00112 template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> ACE_INLINE int
00113 ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::protect (void *addr,
00114                                                              size_t len,
00115                                                              int flags)
00116 {
00117   ACE_TRACE ("ACE_Malloc_T<MEMORY_POOL, ACE_LOCK, ACE_CB>::protect");
00118   return this->memory_pool_.protect (addr, len, flags);
00119 }
00120 
00121 template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> ACE_INLINE ACE_LOCK &
00122 ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::mutex (void)
00123 {
00124   return *this->lock_;
00125 }
00126 
00127 template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> ACE_INLINE void *
00128 ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::base_addr (void)
00129 {
00130   return this->cb_ptr_;
00131 }
00132 
00133 template <ACE_MEM_POOL_1, class ACE_LOCK> ACE_INLINE
00134 ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::ACE_Malloc (const ACE_TCHAR *pool_name)
00135   : ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_Control_Block> (pool_name)
00136 {
00137 }
00138 
00139 template <ACE_MEM_POOL_1, class ACE_LOCK> ACE_INLINE
00140 ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::ACE_Malloc (const ACE_TCHAR *pool_name,
00141                                                   const ACE_TCHAR *lock_name,
00142                                                   const ACE_MEM_POOL_OPTIONS *options)
00143   : ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_Control_Block> (pool_name, lock_name, options)
00144 {
00145 }
00146 
00147 #if !defined (ACE_HAS_TEMPLATE_TYPEDEFS)
00148 template <ACE_MEM_POOL_1, class ACE_LOCK> ACE_INLINE
00149 ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::ACE_Malloc (const ACE_TCHAR *pool_name,
00150                                                   const ACE_TCHAR *lock_name,
00151                                                   const void *options)
00152   : ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_Control_Block> (pool_name, lock_name, options)
00153 {
00154 }
00155 #endif /* !ACE_HAS_TEMPLATE_TYPEDEFS */
00156 
00157 template <ACE_MEM_POOL_1, class ACE_LOCK> ACE_INLINE
00158 ACE_Malloc_LIFO_Iterator<ACE_MEM_POOL_2, ACE_LOCK>::ACE_Malloc_LIFO_Iterator (ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK> &malloc,
00159                                                                               const char *name)
00160   : ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_Control_Block> (malloc, name)
00161 {
00162 }
00163 
00164 template <ACE_MEM_POOL_1, class ACE_LOCK> ACE_INLINE
00165 ACE_Malloc_FIFO_Iterator<ACE_MEM_POOL_2, ACE_LOCK>::ACE_Malloc_FIFO_Iterator (ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK> &malloc,
00166                                                                               const char *name)
00167   : ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_Control_Block> (malloc, name)
00168 {
00169 }
00170 
00171 
00172 #if 0
00173 template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> ACE_INLINE void
00174 ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::init_malloc_header_ptr (void* ptr)
00175 {
00176 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
00177   new (ptr) ACE_MALLOC_HEADER_PTR (this->cb_ptr_, 0);
00178 #else
00179   ACE_UNUSED_ARG (ptr);
00180 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
00181 }
00182 #endif  /* 0 */
00183 
00184 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:41:54 2006 for ACE by doxygen 1.3.6