summaryrefslogtreecommitdiff
path: root/ace/Filecache.cpp
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-06-01 22:07:53 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-06-01 22:07:53 +0000
commitf237ccbb8414a63231dbef45df8fb42b48a3b923 (patch)
tree0480fc2a840f47762f1ecff517f99240fbae51e0 /ace/Filecache.cpp
parent7ea34bd80216c224677ced47de722c0a79be4913 (diff)
downloadATCD-f237ccbb8414a63231dbef45df8fb42b48a3b923.tar.gz
Modified double-checking pattern
Diffstat (limited to 'ace/Filecache.cpp')
-rw-r--r--ace/Filecache.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/ace/Filecache.cpp b/ace/Filecache.cpp
index 5662fc3a3ea..484c41c03c2 100644
--- a/ace/Filecache.cpp
+++ b/ace/Filecache.cpp
@@ -35,6 +35,7 @@ static const int WRITE_FLAGS = O_RDWR | O_CREAT | O_TRUNC;
// static data members
ACE_Filecache *ACE_Filecache::cvf_ = 0;
+int ACE_Filecache::instantiated_ = 0;
void
ACE_Filecache_Handle::init (void)
@@ -186,7 +187,7 @@ ACE_Filecache *
ACE_Filecache::instance (void)
{
// Double check locking pattern.
- if (ACE_Filecache::cvf_ == 0)
+ if (ACE_Filecache::instantiated_ == 0)
{
ACE_SYNCH_RW_MUTEX &lock =
*ACE_Managed_Object<ACE_SYNCH_RW_MUTEX>::get_preallocated_object
@@ -195,8 +196,14 @@ ACE_Filecache::instance (void)
// @@ James, please check each of the ACE_NEW_RETURN calls to
// make sure that it is safe to return if allocation fails.
- if (ACE_Filecache::cvf_ == 0)
- ACE_NEW_RETURN (ACE_Filecache::cvf_, ACE_Filecache, 0);
+ if (ACE_Filecache::instantiated_ == 0)
+ {
+ ACE_NEW_RETURN (ACE_Filecache::cvf_, ACE_Filecache, 0);
+ ACE_Filecache::instantiated_ = -1;
+ // @@ There's no cleanup routine for ACE_Filecache singleton
+ // at this moment. Don't forget to reset <instantiated_> to
+ // 0 after destructing it.
+ }
}
return ACE_Filecache::cvf_;