diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-04 03:15:01 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-04 03:15:01 +0000 |
commit | fffcb816cda4892937e9fae3ea61560c6846a637 (patch) | |
tree | 6160689e893cc736c387f8401d8fb622b2b14d94 /ace/Object_Manager.cpp | |
parent | 4002966d2a7c47247e5dfdbb052548638905552d (diff) | |
download | ATCD-fffcb816cda4892937e9fae3ea61560c6846a637.tar.gz |
ChangeLogTag:Sat Jul 3 22:12:07 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
Diffstat (limited to 'ace/Object_Manager.cpp')
-rw-r--r-- | ace/Object_Manager.cpp | 108 |
1 files changed, 57 insertions, 51 deletions
diff --git a/ace/Object_Manager.cpp b/ace/Object_Manager.cpp index 9ce357842aa..0d7f1b04e85 100644 --- a/ace/Object_Manager.cpp +++ b/ace/Object_Manager.cpp @@ -403,39 +403,41 @@ ACE_Object_Manager::get_singleton_lock (ACE_Thread_Mutex *&lock) if (lock == 0) { if (starting_up () || shutting_down ()) - // The Object_Manager and its internal lock have not been - // constructed yet. Therefore, the program is single- - // threaded at this point. Or, the ACE_Object_Manager - // instance has been destroyed, so the internal lock is not - // available. Either way, we can not use double-checked - // locking. So, we'll leak the lock. - ACE_NEW_RETURN (lock, - ACE_Thread_Mutex, - -1); - } - else - { - // Allocate a new lock, but use double-checked locking to - // ensure that only one thread allocates it. - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, - ace_mon, - *ACE_Object_Manager::instance ()-> - internal_lock_, - -1)); - - if (lock == 0) { - ACE_Cleanup_Adapter<ACE_Thread_Mutex> *lock_adapter; - ACE_NEW_RETURN (lock_adapter, - ACE_Cleanup_Adapter<ACE_Thread_Mutex>, + // The Object_Manager and its internal lock have not been + // constructed yet. Therefore, the program is single- + // threaded at this point. Or, the ACE_Object_Manager + // instance has been destroyed, so the internal lock is not + // available. Either way, we can not use double-checked + // locking. So, we'll leak the lock. + ACE_NEW_RETURN (lock, + ACE_Thread_Mutex, -1); - lock = &lock_adapter->object (); - - // Register the lock for destruction at program - // termination. This call will cause us to grab the - // ACE_Object_Manager::instance ()->internal_lock_ - // again; that's why it is a recursive lock. - ACE_Object_Manager::at_exit (lock_adapter); + } + else + { + // Allocate a new lock, but use double-checked locking to + // ensure that only one thread allocates it. + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, + ace_mon, + *ACE_Object_Manager::instance ()-> + internal_lock_, + -1)); + + if (lock == 0) + { + ACE_Cleanup_Adapter<ACE_Thread_Mutex> *lock_adapter; + ACE_NEW_RETURN (lock_adapter, + ACE_Cleanup_Adapter<ACE_Thread_Mutex>, + -1); + lock = &lock_adapter->object (); + + // Register the lock for destruction at program + // termination. This call will cause us to grab the + // ACE_Object_Manager::instance ()->internal_lock_ + // again; that's why it is a recursive lock. + ACE_Object_Manager::at_exit (lock_adapter); + } } } @@ -448,16 +450,18 @@ ACE_Object_Manager::get_singleton_lock (ACE_Mutex *&lock) if (lock == 0) { if (starting_up () || shutting_down ()) - // The Object_Manager and its internal lock have not been - // constructed yet. Therefore, the program is single- - // threaded at this point. Or, the ACE_Object_Manager - // instance has been destroyed, so the internal lock is not - // available. Either way, we can not use double-checked - // locking. So, we'll leak the lock. - - ACE_NEW_RETURN (lock, - ACE_Mutex, - -1); + { + // The Object_Manager and its internal lock have not been + // constructed yet. Therefore, the program is single- + // threaded at this point. Or, the ACE_Object_Manager + // instance has been destroyed, so the internal lock is not + // available. Either way, we can not use double-checked + // locking. So, we'll leak the lock. + + ACE_NEW_RETURN (lock, + ACE_Mutex, + -1); + } else { // Allocate a new lock, but use double-checked locking to @@ -530,16 +534,18 @@ ACE_Object_Manager::get_singleton_lock (ACE_RW_Thread_Mutex *&lock) if (lock == 0) { if (starting_up () || shutting_down ()) - // The Object_Manager and its internal lock have not been - // constructed yet. Therefore, the program is single- - // threaded at this point. Or, the ACE_Object_Manager - // instance has been destroyed, so the internal lock is not - // available. Either way, we can not use double-checked - // locking. So, we'll leak the lock. - - ACE_NEW_RETURN (lock, - ACE_RW_Thread_Mutex, - -1); + { + // The Object_Manager and its internal lock have not been + // constructed yet. Therefore, the program is single- + // threaded at this point. Or, the ACE_Object_Manager + // instance has been destroyed, so the internal lock is not + // available. Either way, we can not use double-checked + // locking. So, we'll leak the lock. + + ACE_NEW_RETURN (lock, + ACE_RW_Thread_Mutex, + -1); + } else { // Allocate a new lock, but use double-checked locking to |