diff options
Diffstat (limited to 'ACE')
-rw-r--r-- | ACE/ChangeLog | 11 | ||||
-rw-r--r-- | ACE/ace/Makefile.am | 1 | ||||
-rw-r--r-- | ACE/ace/Service_Config.cpp | 61 | ||||
-rw-r--r-- | ACE/ace/Service_Config.h | 33 | ||||
-rw-r--r-- | ACE/ace/Threading_Helper_T.cpp | 83 |
5 files changed, 94 insertions, 95 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index 91fd426d4ce..e59ed37e812 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,14 @@ +Mon Apr 14 11:08:57 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl> + + * ace/Threading_Helper_T.cpp: + Removed + + * ace/Makefile.am: + Removed file above + + * ace/Service_Config.{h,cpp,inl}: + Changed the template instantiations like we have for Atomic_Op. + Mon Apr 14 09:54:57 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl> * tests/tests.mpc: diff --git a/ACE/ace/Makefile.am b/ACE/ace/Makefile.am index dadd84d368f..cf0bd5ab80a 100644 --- a/ACE/ace/Makefile.am +++ b/ACE/ace/Makefile.am @@ -1027,7 +1027,6 @@ nobase_include_HEADERS += \ Thread_Mutex.inl \ Thread_Semaphore.h \ Thread_Semaphore.inl \ - Threading_Helper_T.cpp \ Throughput_Stats.h \ Time_Value.h \ Time_Value.inl \ diff --git a/ACE/ace/Service_Config.cpp b/ACE/ace/Service_Config.cpp index ddc14dc6e4d..c4bd580b70a 100644 --- a/ACE/ace/Service_Config.cpp +++ b/ACE/ace/Service_Config.cpp @@ -30,6 +30,67 @@ ACE_RCSID (ace, ACE_BEGIN_VERSIONED_NAMESPACE_DECL +ACE_Threading_Helper<ACE_Thread_Mutex>::~ACE_Threading_Helper () +{ + ACE_OS::thr_key_detach (this->key_, 0); + ACE_OS::thr_keyfree (this->key_); +} + +ACE_Threading_Helper<ACE_Thread_Mutex>::ACE_Threading_Helper () + : key_ (ACE_OS::NULL_key) +{ +# if defined (ACE_HAS_TSS_EMULATION) + ACE_Object_Manager::init_tss (); +# endif + + if (ACE_Thread::keycreate (&key_, 0, 0) == -1) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) Failed to create thread key: %p\n"), + "")); + } +} + +void +ACE_Threading_Helper<ACE_Thread_Mutex>::set (void* p) +{ + if (ACE_Thread::setspecific (key_, p) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) Service Config failed to set thread key value: %p\n"), + "")); +} + +void* +ACE_Threading_Helper<ACE_Thread_Mutex>::get (void) +{ + void* temp = 0; + if (ACE_Thread::getspecific (key_, &temp) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%P|%t) Service Config failed to get thread key value: %p\n"), + ""), + 0); + return temp; +} + +ACE_Threading_Helper<ACE_Null_Mutex>::~ACE_Threading_Helper () +{ +} + +ACE_Threading_Helper<ACE_Null_Mutex>::ACE_Threading_Helper () +{ +} + +void +ACE_Threading_Helper<ACE_Null_Mutex>::set (void*) +{ +} + +void* +ACE_Threading_Helper<ACE_Null_Mutex>::get (void) +{ + return ACE_Service_Config::singleton()->instance_.get (); +} + /** * @c ACE_Service_Config is supposed to be a Singleton. This is the * only Configuration Gestalt available for access from static diff --git a/ACE/ace/Service_Config.h b/ACE/ace/Service_Config.h index 35177e3bcbb..c8d79020a55 100644 --- a/ACE/ace/Service_Config.h +++ b/ACE/ace/Service_Config.h @@ -150,6 +150,14 @@ public: template <typename LOCK> class ACE_Threading_Helper { +}; + +/* + * Specialization for a multi threaded program + */ +template<> +class ACE_Export ACE_Threading_Helper<ACE_Thread_Mutex> +{ public: ACE_Threading_Helper (); ~ACE_Threading_Helper (); @@ -158,12 +166,25 @@ public: void* get (void); private: - /// Key for the thread-specific data, which is a simple pointer to /// the thread's (currently-) global configuration context. ACE_thread_key_t key_; }; +/* + * Specialization for a single threaded program + */ +template<> +class ACE_Export ACE_Threading_Helper<ACE_Null_Mutex> +{ +public: + ACE_Threading_Helper (); + ~ACE_Threading_Helper (); + + void set (void*); + void* get (void); +}; + #define ACE_Component_Config ACE_Service_Config /** @@ -651,16 +672,6 @@ ACE_END_VERSIONED_NAMESPACE_DECL #include "ace/Service_Config.inl" #endif /* __ACE_INLINE__ */ -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Threading_Helper_T.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Threading_Helper_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - - - #include /**/ "ace/post.h" #endif /* ACE_SERVICE_CONFIG_H */ diff --git a/ACE/ace/Threading_Helper_T.cpp b/ACE/ace/Threading_Helper_T.cpp deleted file mode 100644 index 11d5bcc77d9..00000000000 --- a/ACE/ace/Threading_Helper_T.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef ACE_THREADING_HELPER_T_CPP -#define ACE_THREADING_HELPER_T_CPP - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_RCSID(ace, - Threading_Helper_T, - "$Id$") - -template <> -ACE_Threading_Helper<ACE_Thread_Mutex>::~ACE_Threading_Helper () -{ - ACE_OS::thr_key_detach (this->key_, 0); - ACE_OS::thr_keyfree (this->key_); -} - -template <> -ACE_Threading_Helper<ACE_Thread_Mutex>::ACE_Threading_Helper () - : key_ (ACE_OS::NULL_key) -{ -# if defined (ACE_HAS_TSS_EMULATION) - ACE_Object_Manager::init_tss (); -# endif - - if (ACE_Thread::keycreate (&key_, 0, 0) == -1) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) Failed to create thread key: %p\n"), - "")); - } -} - -template <> void -ACE_Threading_Helper<ACE_Thread_Mutex>::set (void* p) -{ - if (ACE_Thread::setspecific (key_, p) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) Service Config failed to set thread key value: %p\n"), - "")); -} - -template <> void* -ACE_Threading_Helper<ACE_Thread_Mutex>::get (void) -{ - void* temp = 0; - if (ACE_Thread::getspecific (key_, &temp) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%P|%t) Service Config failed to get thread key value: %p\n"), - ""), - 0); - return temp; -} - -template <> -ACE_Threading_Helper<ACE_Null_Mutex>::~ACE_Threading_Helper () -{ -} - -template <> -ACE_Threading_Helper<ACE_Null_Mutex>::ACE_Threading_Helper () - : key_ (ACE_OS::NULL_key) -{ -} - -template <> void -ACE_Threading_Helper<ACE_Null_Mutex>::set (void*) -{ -} - -template <> void* -ACE_Threading_Helper<ACE_Null_Mutex>::get (void) -{ - return ACE_Service_Config::singleton()->instance_.get (); -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* ACE_THREADING_HELPER_T_CPP */ - |