diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 2004-07-10 03:27:27 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 2004-07-10 03:27:27 +0000 |
commit | 89084e85a39a0ffdaf709d02bfa3b58bf7ece4b0 (patch) | |
tree | ce71068c929bd190ea189d7e340dabc0c0266d5c | |
parent | e7e03491ed05b8c97a0ffa891314fe4565569744 (diff) | |
download | ATCD-89084e85a39a0ffdaf709d02bfa3b58bf7ece4b0.tar.gz |
ChangeLogTag:Fri Jul 9 21:23:13 2004 Douglas C. Schmidt <schmidt@cs.wustl.edu>
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | TAO/docs/components.html | 4 | ||||
-rw-r--r-- | TAO/docs/performance.html | 6 | ||||
-rw-r--r-- | THANKS | 1 | ||||
-rw-r--r-- | ace/Global_Macros.h | 6 | ||||
-rw-r--r-- | ace/RB_Tree.cpp | 90 | ||||
-rw-r--r-- | ace/RB_Tree.h | 31 | ||||
-rw-r--r-- | ace/RB_Tree.inl | 10 |
8 files changed, 116 insertions, 45 deletions
diff --git a/ChangeLog b/ChangeLog index 9a6389bd429..69a14364469 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Fri Jul 9 21:23:13 2004 Douglas C. Schmidt <schmidt@cs.wustl.edu> + + * ace/RB_Tree.{h,inl,cpp}: Fixed a number of bugs pertaining to + ACE_RB_Tree's failure to use its allocators correctly. Thanks + to Lothar Werzinger <lothar@xcerla.com> for these fixes. + + * ace/Global_Macros.h: Added macros for ACE_SOCK_DGRAM, + ACE_SOCK_DGRAM_MCAST, and ACE_SOCK_DGRAM_BCAST so they will work + on compilers like MIPSPro v.7.41 that don't support template + typedefs. Thanks to Brian Waltersdorf + <brian.j.waltersdorf@boeing.com> for reporting this and + suggesting a fix. + Thu Jul 8 16:00:29 2004 Steve Huston <shuston@riverace.com> * ace/Timer_Queue_Adapters.h: If ACE_HAS_DEFERRED_TIMER_COMMANDS is diff --git a/TAO/docs/components.html b/TAO/docs/components.html index 12749ed6215..dcd890a3473 100644 --- a/TAO/docs/components.html +++ b/TAO/docs/components.html @@ -39,8 +39,8 @@ bgcolor="#ffffff"> <li><a href="performance.html">Performance tuning</a> describes how to optimize the throughput, scalability, and latency of TAO to meet various application needs. It also describes how to - reduce the compilation times for ACE+TAO and its - applications. <P> + reduce the compilation times and memory footprints for + ACE+TAO and its applications. <P> </UL> </BODY> diff --git a/TAO/docs/performance.html b/TAO/docs/performance.html index 1d64cda5ffd..ee9aeade31e 100644 --- a/TAO/docs/performance.html +++ b/TAO/docs/performance.html @@ -2,13 +2,13 @@ <html> <head> <!-- $Id$ --> - <title>TAO Performance Tuning</title> + <title>TAO Performance and Footprint Tuning</title> <LINK href="tao.css" rel="stylesheet" type="text/css"> </head> <body> <hr><p> - <h3>TAO Compile-time and Run-time Performance Tuning</h3> + <h3>TAO Compile-time and Run-time Performance and Footprint Tuning</h3> <a name="overview"></a> <h3>Overview</h3> @@ -618,7 +618,7 @@ CC 5.3 compiler gives a big footprint reduction of the order of 40%. <address><a href="mailto:ossama@uci.edu">Ossama Othman</a></address> <!-- Created: Mon Nov 26 13:22:00 PST 2001 --> <!-- hhmts start --> -Last modified: Wed Dec 25 06:23:55 CST 2002 +Last modified: Fri Jul 9 22:16:12 CDT 2004 <!-- hhmts end --> </body> </html> @@ -1904,6 +1904,7 @@ Mattias Nilsson <mattias dot o dot nilsson at ericsson dot com> Michael Hollins <michael dot hollins at silverbrookresearch dot com> Dave Knox <david dot knox at Intrado dot com> Lance Paine <lance at ams dot co dot nz> +Brian Waltersdorf <brian dot j dot waltersdorf at boeing dot com> I would particularly like to thank Paul Stephenson, who worked with me at Ericsson in the early 1990's. Paul devised the recursive Makefile diff --git a/ace/Global_Macros.h b/ace/Global_Macros.h index d1c865c048c..f7497402918 100644 --- a/ace/Global_Macros.h +++ b/ace/Global_Macros.h @@ -877,6 +877,9 @@ _make_##SERVICE_CLASS (ACE_Service_Object_Exterminator *gobbler) \ # define ACE_SOCK_ACCEPTOR ACE_SOCK_Acceptor # define ACE_SOCK_CONNECTOR ACE_SOCK_Connector # define ACE_SOCK_STREAM ACE_SOCK_Stream +# define ACE_SOCK_DGRAM ACE_SOCK_Dgram +# define ACE_SOCK_DGRAM_BCAST ACE_SOCK_Dgram_Bcast +# define ACE_SOCK_DGRAM_MCAST ACE_SOCK_Dgram_Mcast // Handle ACE_SOCK_SEQPACK_* # define ACE_SOCK_SEQPACK_ACCEPTOR ACE_SOCK_SEQPACK_Acceptor @@ -963,6 +966,9 @@ _make_##SERVICE_CLASS (ACE_Service_Object_Exterminator *gobbler) \ # define ACE_SOCK_ACCEPTOR ACE_SOCK_Acceptor, ACE_INET_Addr # define ACE_SOCK_CONNECTOR ACE_SOCK_Connector, ACE_INET_Addr # define ACE_SOCK_STREAM ACE_SOCK_Stream, ACE_INET_Addr +# define ACE_SOCK_DGRAM ACE_SOCK_Dgram, ACE_INET_Addr +# define ACE_SOCK_DGRAM_BCAST ACE_SOCK_Dgram_Bcast, ACE_INET_Addr +# define ACE_SOCK_DGRAM_MCAST ACE_SOCK_Dgram_Mcast, ACE_INET_Addr // Handle ACE_SOCK_SEQPACK_* # define ACE_SOCK_SEQPACK_ACCEPTOR ACE_SOCK_SEQPACK_Acceptor, ACE_Multihomed_INET_Addr diff --git a/ace/RB_Tree.cpp b/ace/RB_Tree.cpp index e819ad5d5ac..0965d4d73b8 100644 --- a/ace/RB_Tree.cpp +++ b/ace/RB_Tree.cpp @@ -5,6 +5,7 @@ #ifndef ACE_RB_TREE_C #define ACE_RB_TREE_C +#include "ace/Global_Macros.h" #include "ace/RB_Tree.h" #include "ace/SString.h" @@ -25,13 +26,14 @@ ACE_RCSID (ace, // Constructor. template <class EXT_ID, class INT_ID> -ACE_RB_Tree_Node<EXT_ID, INT_ID>::ACE_RB_Tree_Node (const EXT_ID &k, const INT_ID &t) +ACE_RB_Tree_Node<EXT_ID, INT_ID>::ACE_RB_Tree_Node (const EXT_ID &k, const INT_ID &t, const ACE_RB_Tree_Base &tree) : k_ (k), t_ (t), color_ (RED), parent_ (0), left_ (0), - right_ (0) + right_ (0), + tree_ (&tree) { ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>::ACE_RB_Tree_Node (const EXT_ID &k, const INT_ID &t)"); } @@ -45,22 +47,30 @@ ACE_RB_Tree_Node<EXT_ID, INT_ID>::~ACE_RB_Tree_Node (void) ACE_TRACE ("ACE_RB_Tree_Node<EXT_ID, INT_ID>::~ACE_RB_Tree_Node"); // Delete left sub-tree. - delete left_; + // Explicitly call the destructor. + ACE_DES_FREE_TEMPLATE2 (left_, + this->tree_->allocator()->free, + ACE_RB_Tree_Node, + EXT_ID, INT_ID); // Delete right sub_tree. - delete right_; + // Explicitly call the destructor. + ACE_DES_FREE_TEMPLATE2 (right_, + this->tree_->allocator()->free, + ACE_RB_Tree_Node, + EXT_ID, INT_ID); } // Constructor. template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree (ACE_Allocator *alloc) - : allocator_ (alloc), - root_ (0), + : root_ (0), current_size_ (0) { ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::" "ACE_RB_Tree (ACE_Allocator *alloc)"); + allocator_ = alloc; if (this->open (alloc) == -1) ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("ACE_RB_Tree::ACE_RB_Tree\n"))); @@ -70,14 +80,14 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree (ACE_Allocator template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree (const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &rbt) - : allocator_ (rbt.allocator_), - root_ (0), + : root_ (0), current_size_ (0) { ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::" "ACE_RB_Tree (const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &rbt)"); ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_); - + allocator_ = rbt.allocator_; + // Make a deep copy of the passed tree. ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> iter(rbt); @@ -535,7 +545,10 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::close_i () { ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::close_i"); - delete root_; + ACE_DES_FREE_TEMPLATE2 (root_, + this->allocator()->free, + ACE_RB_Tree_Node, + EXT_ID, INT_ID); current_size_ = 0; root_ = 0; @@ -609,9 +622,12 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, // The right subtree is empty: insert new node there. ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0; - ACE_NEW_RETURN (tmp, - (ACE_RB_Tree_Node<EXT_ID, INT_ID>) (k, t), - 0); + void *ptr = 0; + ACE_ALLOCATOR_RETURN (ptr, + this->allocator_->malloc (sizeof(ACE_RB_Tree_Node<EXT_ID, INT_ID>)), + 0); + tmp = new (ptr) ACE_RB_Tree_Node<EXT_ID, INT_ID>(k, t, *this); + current->right (tmp); // If the node was successfully inserted, set its @@ -640,9 +656,11 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, { // The left subtree is empty: insert new node there. ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0; - ACE_NEW_RETURN (tmp, - (ACE_RB_Tree_Node<EXT_ID, INT_ID>) (k, t), - 0); + void *ptr = 0; + ACE_ALLOCATOR_RETURN (ptr, + this->allocator_->malloc (sizeof(ACE_RB_Tree_Node<EXT_ID, INT_ID>)), + 0); + tmp = new (ptr) ACE_RB_Tree_Node<EXT_ID, INT_ID>(k, t, *this); current->left (tmp); // If the node was successfully inserted, set its @@ -661,9 +679,12 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, { // The tree is empty: insert at the root and color the root // black. - ACE_NEW_RETURN (root_, - (ACE_RB_Tree_Node<EXT_ID, INT_ID>) (k, t), - 0); + void * ptr = 0; + ACE_ALLOCATOR_RETURN (ptr, + this->allocator_->malloc (sizeof(ACE_RB_Tree_Node<EXT_ID, INT_ID>)), + 0); + root_ = new (ptr) ACE_RB_Tree_Node<EXT_ID, INT_ID>(k, t, *this); + if (root_) { root_->color (ACE_RB_Tree_Node_Base::BLACK); @@ -720,9 +741,12 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, { // The right subtree is empty: insert new node there. ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0; - ACE_NEW_RETURN (tmp, - (ACE_RB_Tree_Node<EXT_ID, INT_ID>) (k, t), - -1); + void * ptr = 0; + ACE_ALLOCATOR_RETURN (ptr, + this->allocator_->malloc (sizeof(ACE_RB_Tree_Node<EXT_ID, INT_ID>)), + -1); + tmp = new (ptr) ACE_RB_Tree_Node<EXT_ID, INT_ID>(k, t, *this); + current->right (tmp); // If the node was successfully inserted, set its parent, rebalance @@ -751,9 +775,11 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, { // The left subtree is empty: insert new node there. ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0; - ACE_NEW_RETURN (tmp, - (ACE_RB_Tree_Node<EXT_ID, INT_ID>) (k, t), - -1); + void * ptr = 0; + ACE_ALLOCATOR_RETURN (ptr, + this->allocator_->malloc (sizeof(ACE_RB_Tree_Node<EXT_ID, INT_ID>)), + -1); + tmp = new (ptr) ACE_RB_Tree_Node<EXT_ID, INT_ID>(k, t, *this); current->left (tmp); // If the node was successfully inserted, set its // parent, rebalance the tree, color the root black, and @@ -770,9 +796,12 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, else { // The tree is empty: insert at the root and color the root black. - ACE_NEW_RETURN (root_, - (ACE_RB_Tree_Node<EXT_ID, INT_ID>) (k, t), - -1); + void * ptr = 0; + ACE_ALLOCATOR_RETURN (ptr, + this->allocator_->malloc (sizeof(ACE_RB_Tree_Node<EXT_ID, INT_ID>)), + -1); + root_ = new (ptr) ACE_RB_Tree_Node<EXT_ID, INT_ID>(k, t, *this); + root_->color (ACE_RB_Tree_Node_Base::BLACK); ++current_size_; entry = root_; @@ -993,7 +1022,10 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (ACE_RB_Tree_Node< y->parent (0); y->right (0); y->left (0); - delete y; + ACE_DES_FREE_TEMPLATE2 (y, + this->allocator()->free, + ACE_RB_Tree_Node, + EXT_ID, INT_ID); --current_size_; return 0; diff --git a/ace/RB_Tree.h b/ace/RB_Tree.h index 44f13416005..6c31c358eef 100644 --- a/ace/RB_Tree.h +++ b/ace/RB_Tree.h @@ -43,6 +43,22 @@ public: enum RB_Tree_Node_Color {RED, BLACK}; }; +class ACE_RB_Tree_Base +{ +public: + /// Search result enumeration. + enum RB_SearchResult {LEFT, EXACT, RIGHT}; + + /// get the allocator; + ACE_Allocator * allocator () const; + +protected: + // = Protected members. + + /// Pointer to a memory allocator. + ACE_Allocator *allocator_; +}; + /** * @class ACE_RB_Tree_Node * @@ -55,7 +71,7 @@ public: // = Initialization and termination methods. /// Constructor. - ACE_RB_Tree_Node (const EXT_ID &k, const INT_ID &t); + ACE_RB_Tree_Node (const EXT_ID &k, const INT_ID &t, const ACE_RB_Tree_Base &tree); /// Destructor. ~ACE_RB_Tree_Node (void); @@ -109,13 +125,9 @@ private: /// Pointer to node's right child. ACE_RB_Tree_Node<EXT_ID, INT_ID> *right_; -}; - -class ACE_RB_Tree_Base -{ -public: - /// Search result enumeration. - enum RB_SearchResult {LEFT, EXACT, RIGHT}; + + /// Pointer to tree base (to get the allocator). + const ACE_RB_Tree_Base *tree_; }; /** @@ -532,9 +544,6 @@ private: // = Private members. - /// Pointer to a memory allocator. - ACE_Allocator *allocator_; - /// Synchronization variable for the MT_SAFE <ACE_RB_Tree>. ACE_LOCK lock_; diff --git a/ace/RB_Tree.inl b/ace/RB_Tree.inl index d90f3c5b8a6..2bcac92801b 100644 --- a/ace/RB_Tree.inl +++ b/ace/RB_Tree.inl @@ -121,6 +121,16 @@ ACE_RB_Tree_Node<EXT_ID, INT_ID>::right (ACE_RB_Tree_Node<EXT_ID, INT_ID> * r) } +//////////////////////////////////////////////////////////////////////// +// class ACE_RB_Tree_Base // +//////////////////////////////////////////////////////////////////////// + +// Accessor for allocator + +ACE_INLINE ACE_Allocator * ACE_RB_Tree_Base::allocator () const +{ + return allocator_; +} //////////////////////////////////////////////////////////////////////// // template class ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> // |