summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/FactoryTable.cpp
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2008-06-05 16:20:05 +0800
committerBenoit Foucher <benoit@zeroc.com>2008-06-06 15:28:20 +0200
commit2942ca65d99dd9ecc4beb9b11dc5fb9a8ec5e305 (patch)
treea0b0006fb6d92ec94d7b2e4b1eb7c8d1ec158ad5 /cpp/src/Ice/FactoryTable.cpp
parenthttp://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=3239 - Under windows stati... (diff)
downloadice-2942ca65d99dd9ecc4beb9b11dc5fb9a8ec5e305.tar.bz2
ice-2942ca65d99dd9ecc4beb9b11dc5fb9a8ec5e305.tar.xz
ice-2942ca65d99dd9ecc4beb9b11dc5fb9a8ec5e305.zip
Get rid of the factory table wrapper.
Diffstat (limited to 'cpp/src/Ice/FactoryTable.cpp')
-rw-r--r--cpp/src/Ice/FactoryTable.cpp50
1 files changed, 40 insertions, 10 deletions
diff --git a/cpp/src/Ice/FactoryTable.cpp b/cpp/src/Ice/FactoryTable.cpp
index 99ae9145596..75420dc4024 100644
--- a/cpp/src/Ice/FactoryTable.cpp
+++ b/cpp/src/Ice/FactoryTable.cpp
@@ -10,24 +10,54 @@
#include <Ice/FactoryTable.h>
#include <Ice/UserExceptionFactory.h>
+namespace IceInternal
+{
+
//
-// This constructor initializes the single global IceInternal::factoryTable instance
-// from the outside (if it hasn't been initialized yet). The constructor here
-// is triggered by a file-static instance of FactoryTable in each
-// slice2cpp-generated header file that uses non-local exceptions or non-abstract classes.
-// This ensures that IceInternal::factoryTable is always initialized before it is used.
+// Single global instance of the factory table for non-local
+// exceptions and non-abstract classes.
//
-IceInternal::FactoryTable::FactoryTable()
+ICE_DECLSPEC_EXPORT FactoryTableDef* factoryTable;
+
+}
+
+namespace
{
- IceInternal::factoryTableWrapper.initialize();
+static int initCount = 0; // Initialization count
+IceUtil::StaticMutex initCountMutex = ICE_STATIC_MUTEX_INITIALIZER;
+
+
+}
+
+//
+// This constructor initializes the single global
+// IceInternal::factoryTable instance from the outside (if it hasn't
+// been initialized yet). The constructor here is triggered by a
+// file-static instance of FactoryTable in each slice2cpp-generated
+// header file that uses non-local exceptions or non-abstract classes.
+// This ensures that IceInternal::factoryTable is always initialized
+// before it is used.
+//
+IceInternal::FactoryTable::FactoryTable()
+{
+ IceUtil::StaticMutex::Lock lock(initCountMutex);
+ if(0 == initCount++)
+ {
+ factoryTable = new FactoryTableDef;
+ }
}
//
-// Similarly, the destructor calls the finalize() method on the factory table wrapper which,
-// once the tables reference count drops to zero, deletes the table.
+// Similarly, the destructor calls the finalize() method on the
+// factory table wrapper which, once the tables reference count drops
+// to zero, deletes the table.
//
IceInternal::FactoryTable::~FactoryTable()
{
- IceInternal::factoryTableWrapper.finalize();
+ IceUtil::StaticMutex::Lock lock(initCountMutex);
+ if(0 == --initCount)
+ {
+ delete factoryTable;
+ }
}