diff options
author | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-08-23 02:03:24 +0000 |
---|---|---|
committer | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-08-23 02:03:24 +0000 |
commit | bde1bd27fdb3e91ca75e218849536ef87063608e (patch) | |
tree | 302c70c05af0ce4f57501d1d2cc492aed480e407 | |
parent | c48f691431eea4c71877dd5dd63d739912c7bbf3 (diff) | |
download | ATCD-bde1bd27fdb3e91ca75e218849536ef87063608e.tar.gz |
*** empty log message ***
-rw-r--r-- | ace/OS.cpp | 21 | ||||
-rw-r--r-- | ace/Synch.cpp | 19 | ||||
-rw-r--r-- | ace/Synch.h | 23 |
3 files changed, 49 insertions, 14 deletions
diff --git a/ace/OS.cpp b/ace/OS.cpp index 28e743c999d..a0dd01133b3 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -1020,10 +1020,6 @@ private: // = Static data. static ACE_TSS_Cleanup *instance_; // Pointer to the singleton instance. - -public: - static ACE_Thread_Mutex lock_; - // Serialize initialization of <key_>. }; // = Static object initialization. @@ -1031,9 +1027,6 @@ public: // Pointer to the singleton instance. ACE_TSS_Cleanup *ACE_TSS_Cleanup::instance_ = 0; -// Serialize initialization of <key_>. -ACE_Thread_Mutex ACE_TSS_Cleanup::lock_; - int ACE_TSS_Cleanup::mark_cleanup_i (void) { @@ -1069,7 +1062,7 @@ ACE_TSS_Cleanup::exit (void *status) // in an array without invoking the according destructors. { - ACE_GUARD (ACE_Thread_Mutex, ace_mon, ACE_TSS_Cleanup::lock_); + ACE_GUARD (ACE_Thread_Mutex, ace_mon, *ACE_TSS_Cleanup_Lock::instance ()); // Prevent recursive deletions @@ -1125,7 +1118,7 @@ ACE_TSS_Cleanup::exit (void *status) // Acquiring ACE_TSS_Cleanup::lock_ to free TLS keys and remove // entries from ACE_TSS_Info table. { - ACE_GUARD (ACE_Thread_Mutex, ace_mon, ACE_TSS_Cleanup::lock_); + ACE_GUARD (ACE_Thread_Mutex, ace_mon, *ACE_TSS_Cleanup_Lock::instance ()); for (int i = 0; i < index; i++) { @@ -1174,7 +1167,7 @@ ACE_TSS_Cleanup::instance (void) if (ACE_TSS_Cleanup::instance_ == 0) { // Insure that we are serialized! - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, ACE_TSS_Cleanup::lock_, 0); + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *ACE_TSS_Cleanup_Lock::instance (), 0); // Now, use the Double-Checked Locking pattern to make sure we // only create the key once. @@ -1191,7 +1184,7 @@ ACE_TSS_Cleanup::insert (ACE_thread_key_t key, void *inst) { // ACE_TRACE ("ACE_TSS_Cleanup::insert"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, ACE_TSS_Cleanup::lock_, -1); + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *ACE_TSS_Cleanup_Lock::instance (), -1); return this->table_.insert (ACE_TSS_Info (key, destructor, inst)); } @@ -1200,7 +1193,7 @@ int ACE_TSS_Cleanup::remove (ACE_thread_key_t key) { // ACE_TRACE ("ACE_TSS_Cleanup::remove"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, ACE_TSS_Cleanup::lock_, -1); + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *ACE_TSS_Cleanup_Lock::instance (), -1); return this->table_.remove (ACE_TSS_Info (key)); } @@ -1208,7 +1201,7 @@ ACE_TSS_Cleanup::remove (ACE_thread_key_t key) int ACE_TSS_Cleanup::detach (void *inst) { - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, ACE_TSS_Cleanup::lock_, -1); + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *ACE_TSS_Cleanup_Lock::instance (), -1); ACE_TSS_Info *key_info = 0; int success = 0; @@ -1250,7 +1243,7 @@ ACE_TSS_Cleanup::detach (ACE_thread_key_t key, ACE_thread_t tid) int ACE_TSS_Cleanup::key_used (ACE_thread_key_t key) { - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, ACE_TSS_Cleanup::lock_, -1); + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *ACE_TSS_Cleanup_Lock::instance (), -1); ACE_TSS_Info *key_info = 0; diff --git a/ace/Synch.cpp b/ace/Synch.cpp index 0d78c6b6a80..5b0e596268b 100644 --- a/ace/Synch.cpp +++ b/ace/Synch.cpp @@ -17,6 +17,10 @@ ACE_Recursive_Thread_Mutex *ACE_Static_Object_Lock::mutex_ = 0; #endif +#if defined (ACE_WIN32) +ACE_Thread_Mutex *ACE_TSS_Cleanup_Lock::mutex_ = 0; +#endif /* ACE_WIN32 */ + ACE_ALLOC_HOOK_DEFINE(ACE_Null_Mutex) ACE_ALLOC_HOOK_DEFINE(ACE_File_Lock) ACE_ALLOC_HOOK_DEFINE(ACE_RW_Process_Mutex) @@ -949,6 +953,21 @@ ACE_Static_Object_Lock::instance (void) return ACE_Static_Object_Lock::mutex_; } +//////////////////////////////////////////////////////////////// +#if defined (ACE_WIN32) + +ACE_Thread_Mutex * +ACE_TSS_Cleanup_Lock::instance (void) +{ + // We assume things before main are single threaded. + if (ACE_TSS_Cleanup_Lock::mutex_ == 0) + ACE_NEW_RETURN (ACE_TSS_Cleanup_Lock::mutex_, + ACE_Thread_Mutex, 0); + return ACE_TSS_Cleanup_Lock::mutex_; +} + +#endif /* ACE_WIN32 */ + #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) // These are only specialized with ACE_HAS_THREADS. template class ACE_Guard<ACE_SYNCH_RW_MUTEX>; diff --git a/ace/Synch.h b/ace/Synch.h index 9621a3a2e1f..4e274339f1d 100644 --- a/ace/Synch.h +++ b/ace/Synch.h @@ -1244,6 +1244,29 @@ private: // pointer to actual lock }; +#if defined (ACE_WIN32) +class ACE_Export ACE_TSS_Cleanup_Lock + // = TITLE + // Provide an interface to access TSS cleanup lock for + // Win32. + // + // = DESCRIPTION + // This class is used to serialize the access + // of ACE_TSS_Cleanup object in OS.cpp. ACE_TSS_Cleanup + // itself is expected to be managed by ACE_Object_Manager + // later, so this class shall be removed/changed in + // the near future. +{ +public: + static ACE_Thread_Mutex *instance (void); + // static lock access point + +private: + static ACE_Thread_Mutex *mutex_; + // pointer to actual lock +}; +#endif /* ACE_WIN32 */ + #endif /* ACE_HAS_THREADS */ #if defined (__ACE_INLINE__) |