diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-06-01 22:07:53 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-06-01 22:07:53 +0000 |
commit | f237ccbb8414a63231dbef45df8fb42b48a3b923 (patch) | |
tree | 0480fc2a840f47762f1ecff517f99240fbae51e0 /ace/Malloc.cpp | |
parent | 7ea34bd80216c224677ced47de722c0a79be4913 (diff) | |
download | ATCD-f237ccbb8414a63231dbef45df8fb42b48a3b923.tar.gz |
Modified double-checking pattern
Diffstat (limited to 'ace/Malloc.cpp')
-rw-r--r-- | ace/Malloc.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ace/Malloc.cpp b/ace/Malloc.cpp index cd85f0a9061..475bd32fb7e 100644 --- a/ace/Malloc.cpp +++ b/ace/Malloc.cpp @@ -15,6 +15,7 @@ // Process-wide ACE_Allocator. ACE_Allocator *ACE_Allocator::allocator_ = 0; +int ACE_Allocator::instantiated_ = 0; // Controls whether the Allocator is deleted when we shut down (we can // only delete it safely if we created it!) This is no longer used; @@ -66,13 +67,13 @@ ACE_Allocator::instance (void) { // ACE_TRACE ("ACE_Allocator::instance"); - if (ACE_Allocator::allocator_ == 0) + if (ACE_Allocator::instantiated_ == 0) { // Perform Double-Checked Locking Optimization. ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, *ACE_Static_Object_Lock::instance (), 0)); - if (ACE_Allocator::allocator_ == 0) + if (ACE_Allocator::instantiated_ == 0) { // Have a seat. We want to avoid ever having to delete the // ACE_Allocator instance, to avoid shutdown order @@ -106,6 +107,8 @@ ACE_Allocator::instance (void) // ACE_Allocator::allocator_ = // (ACE_New_Allocator *) // new (&allocator_instance) ACE_New_Allocator; + + ACE_Allocator::instantiated_ = -1; } } @@ -124,6 +127,7 @@ ACE_Allocator::instance (ACE_Allocator *r) ACE_Allocator::delete_allocator_ = 0; ACE_Allocator::allocator_ = r; + ACE_Allocator::instantiated_ = (r != 0 ? -1 : 0); return t; } @@ -140,6 +144,7 @@ ACE_Allocator::close_singleton (void) // This should never be executed. See ACE_Allocator::instance (void). delete ACE_Allocator::allocator_; ACE_Allocator::allocator_ = 0; + ACE_Allocator::instantiated_ = 0; ACE_Allocator::delete_allocator_ = 0; } } |