diff options
-rw-r--r-- | ChangeLog | 35 | ||||
-rw-r--r-- | ace/Hash_Map_Manager_T.cpp | 19 | ||||
-rw-r--r-- | ace/Hash_Map_Manager_T.h | 93 | ||||
-rw-r--r-- | ace/Hash_Map_Manager_T.inl | 24 | ||||
-rw-r--r-- | ace/Hash_Map_With_Allocator_T.h | 4 | ||||
-rw-r--r-- | ace/Hash_Map_With_Allocator_T.inl | 23 | ||||
-rw-r--r-- | ace/Local_Name_Space_T.cpp | 15 | ||||
-rw-r--r-- | ace/Name_Space.h | 3 |
8 files changed, 163 insertions, 53 deletions
diff --git a/ChangeLog b/ChangeLog index 5d4f15c4f0c..59aff3f9b4e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +Fri Jun 9 14:06:52 UTC 2006 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu> + + * ace/Hash_Map_With_Allocator_T.{h,inl,cpp}: Enhanced this class + so that it compiles with the new "two allocator" + ACE_Hash_Map_Manager_Ex class. This class needs to be improved + so that it actually leverages the two allocator features, but + that's something for the future. + +Fri Jun 9 13:15:38 UTC 2006 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu> + + * ace/Hash_Map_Manager_T.h: Clarified the meaning of the + constructor and open() parameters. + +Fri Jun 9 13:07:40 UTC 2006 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu> + + * ace/Hash_Map_Manager_T.cpp (open): If the user doesn't supply an + entry_alloc pointer then use the table_alloc pointer. + +Fri Jun 9 13:00:22 UTC 2006 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu> + + * ace/Hash_Map_Manager_T.cpp (open): Zapped the use of ACE_ASSERT + and replaced it with and if statement. We shouldn't be using + ACE_ASSERT in ACE library code.. + +Fri Jun 9 12:53:48 UTC 2006 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu> + + * ace/Hash_Map_Manager_T.{h,inl,cpp}: Added support for a separate + allocator for creating the entries in the chain of + ACE_Hash_Map_Entry objects in the buckets. There are now two + allocators, one for the bucket table and the other for the + entries in the buckets. Thanks to Jaroslaw Nozderko <jaroslaw + dot nozderko at polkomtel dot com dot pl> for this fix. + Fri Jun 9 14:04:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl> * ace/ace_for_tao.mpc: @@ -16,6 +49,7 @@ Fri Jun 9 13:58:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl> * ace/FILE_IO.cpp: Added static cast from ACE_LOFF_T to size_t +>>>>>>> 4.10437 Fri Jun 9 13:42:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl> * ace/OS_NS_sys_stat.inl: @@ -98,6 +132,7 @@ Fri Jun 9 07:55:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl> of bugzilla bug 2359, thanks to Olivier Brunet <o dot brunet at free dot fr> for reporting this. +>>>>>>> 4.10432 Thu Jun 8 17:13:42 UTC 2006 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu> * ace/String_Base.h, diff --git a/ace/Hash_Map_Manager_T.cpp b/ace/Hash_Map_Manager_T.cpp index 4d20b98e16c..eec765cdbeb 100644 --- a/ace/Hash_Map_Manager_T.cpp +++ b/ace/Hash_Map_Manager_T.cpp @@ -9,7 +9,7 @@ // Hash_Map_Manager_T.cpp // // = AUTHOR -// Doug Schmidt +// Douglas C. Schmidt <schmidt@cse.wustl.edu> // // ============================================================================ @@ -87,7 +87,8 @@ ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("total_size_ = %d"), this->total_size_)); ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ncur_size_ = %d"), this->cur_size_)); - this->allocator_->dump (); + this->table_allocator_->dump (); + this->entry_allocator_->dump (); this->lock_.dump (); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); #endif /* ACE_HAS_DUMP */ @@ -100,7 +101,7 @@ ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::creat void *ptr; ACE_ALLOCATOR_RETURN (ptr, - this->allocator_->malloc (bytes), + this->table_allocator_->malloc (bytes), -1); this->table_ = (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *) ptr; @@ -130,10 +131,10 @@ ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::open if (alloc == 0) alloc = ACE_Allocator::instance (); - this->allocator_ = alloc; + this->table_allocator_ = alloc; if (entry_alloc == 0) - entry_alloc = ACE_Allocator::instance (); + entry_alloc = alloc; this->entry_allocator_ = entry_alloc; @@ -141,7 +142,8 @@ ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::open // happen, but did with Sun C++ 4.1 (before a change to this class // was made: it used to have an enum that was supposed to be defined // to be ACE_DEFAULT_MAP_SIZE, but instead was defined to be 0). - ACE_ASSERT (size != 0); + if (size != 0) + return -1; return this->create_buckets (size); } @@ -161,7 +163,8 @@ ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::close { // Destroy the dummy entry. ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry = &this->table_[i]; - // The "if" second argument results in a no-op instead of + + // The second argument results in a no-op instead of // deallocation. ACE_DES_FREE_TEMPLATE2 (entry, ACE_NOOP, ACE_Hash_Map_Entry, EXT_ID, INT_ID); @@ -171,7 +174,7 @@ ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::close this->total_size_ = 0; // Free table memory. - this->allocator_->free (this->table_); + this->table_allocator_->free (this->table_); // Should be done last... this->table_ = 0; diff --git a/ace/Hash_Map_Manager_T.h b/ace/Hash_Map_Manager_T.h index 5a61f717012..2f496ea107a 100644 --- a/ace/Hash_Map_Manager_T.h +++ b/ace/Hash_Map_Manager_T.h @@ -153,18 +153,50 @@ public: // = Initialization and termination methods. - /// Initialize a <Hash_Map_Manager_Ex> with default size. - ACE_Hash_Map_Manager_Ex (ACE_Allocator *alloc = 0, + /** + * Initialize a @c Hash_Map_Manager_Ex with default size elements. + * @param table_alloc is a pointer to a memory allocator used for + * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>). + * @param entry_alloc is a pointer to an additional allocator for + * entries, so it should be able to allocate 'size' / chunks + * of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each. + * If @c table_alloc is 0 it defaults to @c ACE_Allocator::instance(). + * If @c entry_alloc is 0 then it defaults to the same allocator as + * @c table_alloc. + */ + ACE_Hash_Map_Manager_Ex (ACE_Allocator *table_alloc = 0, ACE_Allocator *entry_alloc = 0); - /// Initialize a <Hash_Map_Manager_Ex> with size <length>. + /** + * Initialize a @c Hash_Map_Manager_Ex with @c size elements. + * @param table_alloc is a pointer to a memory allocator used for + * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>). + * @param entry_alloc is a pointer to an additional allocator for + * entries, so it should be able to allocate 'size' / chunks + * of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each. + * If @c table_alloc is 0 it defaults to @c ACE_Allocator::instance(). + * If @c entry_alloc is 0 then it defaults to the same allocator as + * @c table_alloc. + */ ACE_Hash_Map_Manager_Ex (size_t size, - ACE_Allocator *alloc = 0, + ACE_Allocator *table_alloc = 0, ACE_Allocator *entry_alloc = 0); - /// Initialize a <Hash_Map_Manager_Ex> with <size> elements. + /** + * Initialize a @c Hash_Map_Manager_Ex with @c size elements. + * @param table_alloc is a pointer to a memory allocator used for + * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>). + * @param entry_alloc is a pointer to an additional allocator for + * entries, so it should be able to allocate 'size' / chunks + * of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each. + * If @c table_alloc is 0 it defaults to @c ACE_Allocator::instance(). + * If @c entry_alloc is 0 then it defaults to the same allocator as + * @c table_alloc. + * @return -1 on failure, 0 on success + */ + int open (size_t size = ACE_DEFAULT_MAP_SIZE, - ACE_Allocator *alloc = 0, + ACE_Allocator *table_alloc = 0, ACE_Allocator *entry_alloc = 0); /// Close down a <Hash_Map_Manager_Ex> and release dynamically allocated @@ -443,19 +475,17 @@ protected: /// locks held. int unbind_all_i (void); - /// Pointer to a memory allocator. - ACE_Allocator *allocator_; + /// Pointer to a memory allocator used for table_, so it should + /// supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>), + ACE_Allocator *table_allocator_; - // - default allocator 'allocator_' is used for table_, so it should - // supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>), - // - additional allocator 'entry_allocator_' will be used for entries, - // so it should be able to allocate 'size' - // chunks of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each. - - // Addidtional allocator for entries: + /// Addidtional allocator for entries, so it should be able to + /// allocate 'size' / chunks of sizeof(ACE_Hash_Map_Entry<EXT_ID, + /// INT_ID>) bytes each. ACE_Allocator *entry_allocator_; - /// Synchronization variable for the MT_SAFE <ACE_Hash_Map_Manager_Ex>. + /// Synchronization variable for the MT_SAFE + /// @c ACE_Hash_Map_Manager_Ex. ACE_LOCK lock_; /// Function object used for hashing keys. @@ -889,12 +919,35 @@ template <class EXT_ID, class INT_ID, class ACE_LOCK> class ACE_Hash_Map_Manager : public ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> { public: - /// Initialize a <Hash_Map_Manager> with default size. - ACE_Hash_Map_Manager (ACE_Allocator *alloc = 0); - /// Initialize a <Hash_Map_Manager> with size <length>. + /** + * Initialize a @c Hash_Map_Manager with default size elements. + * @param table_alloc is a pointer to a memory allocator used for + * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>). + * @param entry_alloc is a pointer to an additional allocator for + * entries, so it should be able to allocate 'size' / chunks + * of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each. + * If @c table_alloc is 0 it defaults to @c ACE_Allocator::instance(). + * If @c entry_alloc is 0 then it defaults to the same allocator as + * @c table_alloc. + */ + ACE_Hash_Map_Manager (ACE_Allocator *table_alloc = 0, + ACE_Allocator *entry_alloc = 0); + + /** + * Initialize a @c Hash_Map_Manager with @c size elements. + * @param table_alloc is a pointer to a memory allocator used for + * table_, so it should supply size*sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>). + * @param entry_alloc is a pointer to an additional allocator for + * entries, so it should be able to allocate 'size' / chunks + * of sizeof(ACE_Hash_Map_Entry<EXT_ID, INT_ID>) bytes each. + * If @c table_alloc is 0 it defaults to @c ACE_Allocator::instance(). + * If @c entry_alloc is 0 then it defaults to the same allocator as + * @c table_alloc. + */ ACE_Hash_Map_Manager (size_t size, - ACE_Allocator *alloc = 0); + ACE_Allocator *table_alloc = 0, + ACE_Allocator *entry_alloc = 0); // = The following two are necessary for template specialization of // ACE_Hash_Map_Manager to work. diff --git a/ace/Hash_Map_Manager_T.inl b/ace/Hash_Map_Manager_T.inl index 401a526b08b..e3e14a4a490 100644 --- a/ace/Hash_Map_Manager_T.inl +++ b/ace/Hash_Map_Manager_T.inl @@ -8,28 +8,28 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::ACE_Hash_Map_Manager_Ex (size_t size, - ACE_Allocator *alloc, + ACE_Allocator *table_alloc, ACE_Allocator *entry_alloc) - : allocator_ (alloc), + : table_allocator_ (table_alloc), entry_allocator_ (entry_alloc), table_ (0), total_size_ (0), cur_size_ (0) { - if (this->open (size, alloc, entry_alloc) == -1) + if (this->open (size, table_alloc, entry_alloc) == -1) ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_Hash_Map_Manager_Ex\n"))); } template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE -ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::ACE_Hash_Map_Manager_Ex (ACE_Allocator *alloc, +ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::ACE_Hash_Map_Manager_Ex (ACE_Allocator *table_alloc, ACE_Allocator *entry_alloc) - : allocator_ (alloc), + : table_allocator_ (table_alloc), entry_allocator_ (entry_alloc), table_ (0), total_size_ (0), cur_size_ (0) { - if (this->open (ACE_DEFAULT_MAP_SIZE, alloc, entry_alloc) == -1) + if (this->open (ACE_DEFAULT_MAP_SIZE, table_alloc, entry_alloc) == -1) ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_Hash_Map_Manager_Ex\n"))); } @@ -924,16 +924,20 @@ ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOC } template <class EXT_ID, class INT_ID, class ACE_LOCK> -ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::ACE_Hash_Map_Manager (ACE_Allocator *alloc) - : ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> (alloc) +ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::ACE_Hash_Map_Manager (ACE_Allocator *table_alloc, + ACE_Allocator *entry_alloc) + : ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> (table_alloc, + entry_alloc) { } template <class EXT_ID, class INT_ID, class ACE_LOCK> ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::ACE_Hash_Map_Manager (size_t size, - ACE_Allocator *alloc) + ACE_Allocator *table_alloc, + ACE_Allocator *entry_alloc) : ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> (size, - alloc) + table_alloc, + entry_alloc) { } diff --git a/ace/Hash_Map_With_Allocator_T.h b/ace/Hash_Map_With_Allocator_T.h index 088956b48a1..1c2413ba3f2 100644 --- a/ace/Hash_Map_With_Allocator_T.h +++ b/ace/Hash_Map_With_Allocator_T.h @@ -42,6 +42,10 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * is meaningful! That is why we need this wrapper, which * insures that appropriate allocator pointer is in place for * each call. + * + * At some point it would be a good idea to update this class to + * use the new "two allocator" technique provided by @c + * ACE_Hash_Map_Manager_Ex. */ template <class EXT_ID, class INT_ID> class ACE_Hash_Map_With_Allocator : diff --git a/ace/Hash_Map_With_Allocator_T.inl b/ace/Hash_Map_With_Allocator_T.inl index 67f2f8247f8..4ba51437abf 100644 --- a/ace/Hash_Map_With_Allocator_T.inl +++ b/ace/Hash_Map_With_Allocator_T.inl @@ -1,5 +1,5 @@ // -*- C++ -*- -// + // $Id$ ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -8,7 +8,8 @@ template <class EXT_ID, class INT_ID> ACE_INLINE int ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::close (ACE_Allocator *alloc) { ACE_TRACE ("ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::close"); - this->allocator_ = alloc; + this->table_allocator_ = alloc; + this->entry_allocator_ = alloc; return this->close_i (); } @@ -18,7 +19,8 @@ ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::bind (const EXT_ID &ext_id, ACE_Allocator *alloc) { ACE_TRACE ("ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::bind"); - this->allocator_ = alloc; + this->table_allocator_ = alloc; + this->entry_allocator_ = alloc; return this->bind_i (ext_id, int_id); } @@ -28,7 +30,8 @@ ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::unbind (const EXT_ID &ext_id, ACE_Allocator *alloc) { ACE_TRACE ("ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::unbind"); - this->allocator_ = alloc; + this->table_allocator_ = alloc; + this->entry_allocator_ = alloc; return this->unbind_i (ext_id, int_id); } @@ -37,7 +40,8 @@ ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::unbind (const EXT_ID &ext_id, ACE_Allocator *alloc) { ACE_TRACE ("ACE_Hash_Map_With_Allocator<EXT_ID>::unbind"); - this->allocator_ = alloc; + this->table_allocator_ = alloc; + this->entry_allocator_ = alloc; return this->unbind_i (ext_id); } @@ -49,7 +53,8 @@ ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::rebind (const EXT_ID &ext_id, ACE_Allocator *alloc) { ACE_TRACE ("ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::rebind"); - this->allocator_ = alloc; + this->table_allocator_ = alloc; + this->entry_allocator_ = alloc; return this->rebind_i (ext_id, int_id, old_ext_id, old_int_id); } @@ -59,7 +64,8 @@ ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::find (const EXT_ID &ext_id, ACE_Allocator *alloc) { ACE_TRACE ("ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::find"); - this->allocator_ = alloc; + this->table_allocator_ = alloc; + this->entry_allocator_ = alloc; return this->find_i (ext_id, int_id); } @@ -68,7 +74,8 @@ ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::find (const EXT_ID &ext_id, ACE_Allocator *alloc) { ACE_TRACE ("ACE_Hash_Map_With_Allocator<EXT_ID, INT_ID>::find"); - this->allocator_ = alloc; + this->table_allocator_ = alloc; + this->entry_allocator_ = alloc; return this->find_i (ext_id); } diff --git a/ace/Local_Name_Space_T.cpp b/ace/Local_Name_Space_T.cpp index 28266896f5a..dbc0121f231 100644 --- a/ace/Local_Name_Space_T.cpp +++ b/ace/Local_Name_Space_T.cpp @@ -30,7 +30,8 @@ ACE_Name_Space_Map<ALLOCATOR>::close (ALLOCATOR *alloc) { ACE_TRACE ("ACE_Name_Space_Map::close"); - this->allocator_ = alloc; + this->table_allocator_ = alloc; + this->entry_allocator_ = alloc; return this->close_i (); } @@ -41,7 +42,8 @@ ACE_Name_Space_Map<ALLOCATOR>::bind (const ACE_NS_String &ext_id, { ACE_TRACE ("ACE_Name_Space_Map::bind"); - this->allocator_ = alloc; + this->table_allocator_ = alloc; + this->entry_allocator_ = alloc; return this->bind_i (ext_id, int_id); } @@ -52,7 +54,8 @@ ACE_Name_Space_Map<ALLOCATOR>::unbind (const ACE_NS_String &ext_id, { ACE_TRACE ("ACE_Name_Space_Map::unbind"); - this->allocator_ = alloc; + this->table_allocator_ = alloc; + this->entry_allocator_ = alloc; return this->unbind_i (ext_id, int_id); } @@ -65,7 +68,8 @@ ACE_Name_Space_Map<ALLOCATOR>::rebind (const ACE_NS_String &ext_id, { ACE_TRACE ("ACE_Name_Space_Map::rebind"); - this->allocator_ = alloc; + this->table_allocator_ = alloc; + this->entry_allocator_ = alloc; return this->rebind_i (ext_id, int_id, old_ext_id, old_int_id); } @@ -76,7 +80,8 @@ ACE_Name_Space_Map<ALLOCATOR>::find (const ACE_NS_String &ext_id, { ACE_TRACE ("ACE_Name_Space_Map::find"); - this->allocator_ = alloc; + this->table_allocator_ = alloc; + this->entry_allocator_ = alloc; return this->find_i (ext_id, int_id); } diff --git a/ace/Name_Space.h b/ace/Name_Space.h index 18bda096326..134d04e8682 100644 --- a/ace/Name_Space.h +++ b/ace/Name_Space.h @@ -6,11 +6,10 @@ * * $Id$ * - * @author Prashant Jain + * @author Prashant Jain <pjain@cse.wustl.edu> */ //========================================================================== - #ifndef ACE_NAME_SPACE_H #define ACE_NAME_SPACE_H |