diff options
author | iliyan <iliyan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-08-22 22:32:10 +0000 |
---|---|---|
committer | iliyan <iliyan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-08-22 22:32:10 +0000 |
commit | 3129e5b4c8e89ce523cc6b0bfaa9d097cd2e8e43 (patch) | |
tree | 7d83c5cc3c5f74047b9ef544baa07de6f21f1c4a /ACE/ace/Service_Gestalt.h | |
parent | 04b751d89846eff8c416cecc8a59ae8353f63ce8 (diff) | |
download | ATCD-3129e5b4c8e89ce523cc6b0bfaa9d097cd2e8e43.tar.gz |
ChangeLogTag: Tue Aug 22 21:43:34 UTC 2006 Iliyan Jeliazkov <iliyan@ociweb.com>
Diffstat (limited to 'ACE/ace/Service_Gestalt.h')
-rw-r--r-- | ACE/ace/Service_Gestalt.h | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/ACE/ace/Service_Gestalt.h b/ACE/ace/Service_Gestalt.h index 1476020fe38..95575a4e74d 100644 --- a/ACE/ace/Service_Gestalt.h +++ b/ACE/ace/Service_Gestalt.h @@ -29,6 +29,7 @@ #include "ace/Singleton.h" #include "ace/OS_NS_signal.h" #include "ace/Synch_Traits.h" +#include "ace/DLL.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -71,8 +72,8 @@ private: /** * Not implemented to enforce no copying */ - ACE_UNIMPLEMENTED_FUNC (ACE_Service_Gestalt(const ACE_Service_Gestalt&)) - ACE_UNIMPLEMENTED_FUNC (ACE_Service_Gestalt& operator=(const ACE_Service_Gestalt&)) + ACE_Service_Gestalt(const ACE_Service_Gestalt&); + ACE_Service_Gestalt& operator=(const ACE_Service_Gestalt&); public: enum @@ -436,8 +437,60 @@ protected: /// the static_svcs_ list. ACE_PROCESSED_STATIC_SVCS* processed_static_svcs_; +private: + + friend class ACE_Service_Type_DLL_Guard; + }; /* class ACE_Service_Gestalt */ +/** + * As dynamic service objects are loaded, static service objects that + * come with the same DLL code, may also be registered. The static + * services however, have no information about the context in which + * their registration takes place and their relation with the DLL is + * lost. A situation can easily arise where the dynamic service object + * is finalized and its DLL - unmapped, but some of the DLL's static + * services may still be around. Their finalization would not be + * possible, if the DLL counting that code is gone. + * + * The guard, when instantiated (on the stack) swaps out the current + * Gestalt and its service repository, and replaces them with a + * "sandbox" Gestalt, which has lifetime sufficient for just the + * current service initialization. Note that this mechanism is + * effective even in the case where a service initialization causes + * re-entry into the Gestalt to load and initialize another service as + * part of the initialization. + * + * If no action is taken (in case of an error, for instance) the guard + * destructor will simply finalize all newly initialized service(s) + * from the sandbox. On the other hand, if initialization is + * successful the service object descriptors are "relocated" to the + * original Gestalt. **During the relocation, all static services are + * "fixed-up" to hold a reference to the DLL they belong + * to. Effectively, a static service, initialized via loading of a + * particular DLL, becomes a dynamic service. Thus the order of + * service finalization does not matter anymore because the DLL will + * be help in memory until the last service object it provides is + * finalized. + */ +class ACE_Service_Type_DLL_Guard +{ +public: + ACE_Service_Type_DLL_Guard (ACE_Service_Gestalt* gestalt); + ~ACE_Service_Type_DLL_Guard (void); + int relocate (const ACE_DLL& adll); + +protected: + // Unimplemented copy ctor and assigment to prohibit instance + // copying. + ACE_Service_Type_DLL_Guard (const ACE_Service_Type_DLL_Guard&); + ACE_Service_Type_DLL_Guard& operator= (const ACE_Service_Type_DLL_Guard&); + +private: + ACE_Service_Gestalt* gestalt_; + ACE_Service_Repository* repo_; + ACE_Service_Gestalt::ACE_PROCESSED_STATIC_SVCS* processed_static_svcs_; +}; ACE_END_VERSIONED_NAMESPACE_DECL |