diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-10-10 22:26:49 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-10-10 22:26:49 +0000 |
commit | c7e5efe344e180726047d2971b65d4bbbdeac04d (patch) | |
tree | b7b59012b17d22d89a6ecf1818bad6a2435cc189 | |
parent | 43f71d9b2cb02365a3cd7bc5545de53e7bb0da69 (diff) | |
download | ATCD-c7e5efe344e180726047d2971b65d4bbbdeac04d.tar.gz |
*** empty log message ***
-rw-r--r-- | ChangeLog-98b | 11 | ||||
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | ace/Service_Config.cpp | 5 | ||||
-rw-r--r-- | ace/Service_Repository.cpp | 68 | ||||
-rw-r--r-- | ace/Service_Repository.h | 67 |
5 files changed, 97 insertions, 55 deletions
diff --git a/ChangeLog-98b b/ChangeLog-98b index eb281ac007e..55c59cbb0bf 100644 --- a/ChangeLog-98b +++ b/ChangeLog-98b @@ -1,3 +1,14 @@ +Sat Oct 10 16:44:24 1998 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/Service_Repository.cpp: Improved the documentation and added + some new ACE_const_casts. Thanks to Eric Palantir + <palantir@net56.net> for motivating this. + + * ace/Service_Config.cpp (open): The logger key should be set to + the static logger key only if the key supplied is EQUAL with the + default logger key. Thanks to Eric Palantir + <palantir@net56.net> for reporting this. + Sat Oct 10 16:28:00 1998 Carlos O'Ryan <coryan@cs.wustl.edu> * ace/Synch.h: @@ -652,6 +652,7 @@ Peter Nordlund <petern@nada.kth.se> Mark Weel <weel@lucent.com> Tres Seaver <tseaver@palladion.com> Erik Koerber <erik.koerber@siemens.at> +Eric R. Medley <palantir@net56.net> I would particularly like to thank Paul Stephenson, who worked with me at Ericsson and is now at ObjectSpace. Paul devised the recursive diff --git a/ace/Service_Config.cpp b/ace/Service_Config.cpp index efa08cb7ec4..a7873dc2cf7 100644 --- a/ace/Service_Config.cpp +++ b/ace/Service_Config.cpp @@ -487,9 +487,10 @@ ACE_Service_Config::open (const ASYS_TCHAR program_name[], LPCTSTR key = logger_key; - if (key == 0 || ACE_OS::strcmp (key, ACE_DEFAULT_LOGGER_KEY)) + if (key == 0 || ACE_OS::strcmp (key, ACE_DEFAULT_LOGGER_KEY) == 0) // Only use the static <logger_key_> if the caller doesn't - // override it in the parameter list. + // override it in the parameter list or if the key supplied is + // equal to the default static logger key. key = ACE_Service_Config::logger_key_; if (ACE_LOG_MSG->open (program_name, diff --git a/ace/Service_Repository.cpp b/ace/Service_Repository.cpp index f92ba7cc640..d80862cde80 100644 --- a/ace/Service_Repository.cpp +++ b/ace/Service_Repository.cpp @@ -44,7 +44,6 @@ ACE_Service_Repository::instance (int size /* = ACE_Service_Repository::DEFAULT_ // Perform Double-Checked Locking Optimization. ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, *ACE_Static_Object_Lock::instance (), 0)); - if (ACE_Service_Repository::svc_rep_ == 0) { ACE_NEW_RETURN (ACE_Service_Repository::svc_rep_, @@ -95,15 +94,10 @@ ACE_Service_Repository::open (int size) { ACE_TRACE ("ACE_Service_Repository::open"); - ACE_Service_Type **temp; - - ACE_NEW_RETURN (temp, + ACE_NEW_RETURN (this->service_vector_, ACE_Service_Type *[size], -1); - - this->service_vector_ = (const ACE_Service_Type **) temp; this->total_size_ = size; - return 0; } @@ -118,7 +112,7 @@ ACE_Service_Repository::ACE_Service_Repository (int size) ASYS_TEXT ("ACE_Service_Repository"))); } -// Finalize (call fini() and possibly delete) all the services. +// Finalize (call <fini> and possibly delete) all the services. int ACE_Service_Repository::fini (void) @@ -128,17 +122,25 @@ ACE_Service_Repository::fini (void) if (this->service_vector_ != 0) { - // Make sure to fini the services in the reverse order in which - // they were added. + // <fini> the services in reverse order. Note that if services + // were removed from the middle of the repository the order + // won't necessarily be maintained since the <remove> method + // performs compaction. However, the common case is not to + // remove services, so typically they are deleted in reverse + // order. + for (int i = this->current_size_ - 1; i >= 0; i--) { if (ACE::debug ()) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("finalizing %s\n"), this->service_vector_[i]->name ())); - ((ACE_Service_Type *) this->service_vector_[i])->fini (); + ACE_Service_Type *s = ACE_const_cast (ACE_Service_Type *, + this->service_vector_[i]); + s->fini (); } } + return 0; } @@ -152,18 +154,24 @@ ACE_Service_Repository::close (void) if (this->service_vector_ != 0) { - // Make sure to remove the services in the reverse order in - // which they were added. - while (this->current_size_ > 0) + // Delete services in reverse order. Note that if services were + // removed from the middle of the repository the order won't + // necessarily be maintained since the <remove> method performs + // compaction. However, the common case is not to remove + // services, so typically they are deleted in reverse order. + + for (int i = this->current_size_ - 1; i >= 0; i--) { - int i = --this->current_size_; - delete (ACE_Service_Type *) this->service_vector_[i]; + s = ACE_const_Cast (ACE_Service_Type *, + this->service_vector_[i]); + delete s; } delete [] this->service_vector_; this->service_vector_ = 0; - this->current_size_ = 0; + this->current_size_ = 0; } + return 0; } @@ -173,12 +181,12 @@ ACE_Service_Repository::~ACE_Service_Repository (void) this->close (); } -// Locate an entry with NAME in the table. If IGNORE_SUSPENDED is set -// then only consider services marked as resumed. If the caller wants -// the located entry, pass back a pointer to the located entry via -// SRP. If NAME is not found -1 is returned. If NAME is found, but -// it is suspended and the caller wants to ignore suspended services a -// -2 is returned. Must be called with locks held. +// Locate an entry with <name> in the table. If <ignore_suspended> is +// set then only consider services marked as resumed. If the caller +// wants the located entry, pass back a pointer to the located entry +// via <srp>. If <name> is not found -1 is returned. If <name> is +// found, but it is suspended and the caller wants to ignore suspended +// services a -2 is returned. Must be called with locks held. int ACE_Service_Repository::find_i (const ASYS_TCHAR name[], @@ -238,7 +246,9 @@ ACE_Service_Repository::insert (const ACE_Service_Type *sr) // Check for self-assignment... if (sr == this->service_vector_[i]) return 0; - delete (ACE_Service_Type *) this->service_vector_[i]; + ACE_Service_Type *s = ACE_const_cast (ACE_Service_Type *, + this->service_vector_[i]); + delete s; this->service_vector_[i] = sr; return 0; } @@ -292,7 +302,7 @@ ACE_Service_Repository::suspend (const ASYS_TCHAR name[], // dynamically unlink it if it was originally dynamically linked. // Since the order of services in the Respository does not matter, we // simply overwrite the entry being deleted with the final entry in -// the array and decrement the <service_count> by 1. +// the array and decrement the <current_size> by 1. int ACE_Service_Repository::remove (const ASYS_TCHAR name[]) @@ -306,9 +316,13 @@ ACE_Service_Repository::remove (const ASYS_TCHAR name[]) return -1; else { - delete (ACE_Service_Type *) this->service_vector_[i]; + ACE_Service_Type *s = ACE_const_cast (ACE_Service_Type *, + this->service_vector_[i]); + delete s; + + --this->current_size_; - if (--this->current_size_ >= 1) + if (this->current_size_ >= 1) this->service_vector_[i] = this->service_vector_[this->current_size_]; return 0; diff --git a/ace/Service_Repository.h b/ace/Service_Repository.h index a2d040f7400..db78ef861dc 100644 --- a/ace/Service_Repository.h +++ b/ace/Service_Repository.h @@ -22,17 +22,26 @@ class ACE_Export ACE_Service_Repository { // = TITLE - // A container for all services offered by a Service - // Configurator-based application. This allows an - // administrative entity to centrally manage and control the - // behavior of application services. + // Contains all the services offered by a Service + // Configurator-based application. // // = DESCRIPTION - // This class contains a vector of <ACE_Service_Types> *'s. + // This class contains a vector of <ACE_Service_Types> *'s and + // allows an administrative entity to centrally manage and + // control the behavior of application services. Note that if + // services are removed from the middle of the repository the + // order won't necessarily be maintained since the <remove> + // method performs compaction. However, the common case is not + // to remove services, so typically they are deleted in the + // reverse order that they were added originally. public: friend class ACE_Service_Repository_Iterator; - enum {DEFAULT_SIZE = 50}; + enum + { + DEFAULT_SIZE = 50 + }; + // = Initialization and termination methods. ACE_Service_Repository (void); // Initialize the repository. @@ -40,27 +49,30 @@ public: ACE_Service_Repository (int size); // Initialize the repository. - static ACE_Service_Repository *instance (int size = ACE_Service_Repository::DEFAULT_SIZE); - // Get pointer to a process-wide <ACE_Service_Repository>. - - static ACE_Service_Repository *instance (ACE_Service_Repository *); - // Set pointer to a process-wide <ACE_Service_Repository> and return - // existing pointer. - - static void close_singleton (void); - // Delete the dynamically allocated Singleton - int open (int size = DEFAULT_SIZE); // Initialize the repository. ~ACE_Service_Repository (void); - // Terminate the repository. + // Close down the repository and free up dynamically allocated + // resources. + + int close (void); + // Close down the repository and free up dynamically allocated + // resources. int fini (void); - // Finalize (call fini() and possibly delete) all the services. + // Finalize all the services by calling <fini> and deleteing + // dynamically allocated services. - int close (void); - // Terminate the repository. + static ACE_Service_Repository *instance (int size = ACE_Service_Repository::DEFAULT_SIZE); + // Get pointer to a process-wide <ACE_Service_Repository>. + + static ACE_Service_Repository *instance (ACE_Service_Repository *); + // Set pointer to a process-wide <ACE_Service_Repository> and return + // existing pointer. + + static void close_singleton (void); + // Delete the dynamically allocated Singleton. // = Search structure operations (all acquire locks as necessary). @@ -113,7 +125,7 @@ private: // Current number of services. int total_size_; - // Maximum number of service. + // Maximum number of services. static ACE_Service_Repository *svc_rep_; // Pointer to a process-wide <ACE_Service_Repository>. @@ -121,7 +133,6 @@ private: static int delete_svc_rep_; // Must delete the <svc_rep_> if non-0. - #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) ACE_Thread_Mutex lock_; // Synchronization variable for the MT_SAFE Repository @@ -130,16 +141,20 @@ private: class ACE_Export ACE_Service_Repository_Iterator { -public: // = TITLE // Iterate through the <ACE_Service_Repository>. - - // = Initialization method. + // + // = DESCRIPTION + // Make sure not to delete entries as the iteration is going on + // since this class is not designed as a "robust" iterator. +public: + // = Initialization and termination methods. ACE_Service_Repository_Iterator (ACE_Service_Repository &sr, int ignored_suspended = 1); + // Constructor. ~ACE_Service_Repository_Iterator (void); - // dtor. + // Destructor. // = Iteration methods. |