summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/CommunicatorI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice/CommunicatorI.cpp')
-rw-r--r--cpp/src/Ice/CommunicatorI.cpp159
1 files changed, 8 insertions, 151 deletions
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp
index de757ed2cde..47092b0adda 100644
--- a/cpp/src/Ice/CommunicatorI.cpp
+++ b/cpp/src/Ice/CommunicatorI.cpp
@@ -71,19 +71,7 @@ printGCStats(const IceInternal::GCStats& stats)
void
Ice::CommunicatorI::destroy()
{
- InstancePtr instance;
-
- {
- RecMutex::Lock sync(*this);
-
- if(_destroyed) // Don't destroy twice.
- {
- return;
- }
- _destroyed = true;
- instance = _instance;
- }
-
+ if(_instance->destroy())
{
IceUtil::StaticMutex::Lock sync(gcMutex);
@@ -117,91 +105,36 @@ Ice::CommunicatorI::destroy()
theCollector = 0; // Force destruction of the collector.
}
}
-
- if(instance)
- {
- instance->destroy();
- }
}
void
Ice::CommunicatorI::shutdown()
{
- ObjectAdapterFactoryPtr objectAdapterFactory;
-
- {
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
- objectAdapterFactory = _instance->objectAdapterFactory();
- }
-
- //
- // We must call shutdown on the object adapter factory outside the
- // synchronization, otherwise the communicator is blocked during
- // shutdown.
- //
- objectAdapterFactory->shutdown();
+ _instance->objectAdapterFactory()->shutdown();
}
void
Ice::CommunicatorI::waitForShutdown()
{
- ObjectAdapterFactoryPtr objectAdapterFactory;
-
- {
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
- objectAdapterFactory = _instance->objectAdapterFactory();
- }
-
- //
- // We must call waitForShutdown on the object adapter factory
- // outside the synchronization, otherwise the communicator is
- // blocked while we wait for shutdown.
- //
- objectAdapterFactory->waitForShutdown();
+ _instance->objectAdapterFactory()->waitForShutdown();
}
ObjectPrx
Ice::CommunicatorI::stringToProxy(const string& s) const
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
return _instance->proxyFactory()->stringToProxy(s);
}
string
Ice::CommunicatorI::proxyToString(const ObjectPrx& proxy) const
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
return _instance->proxyFactory()->proxyToString(proxy);
}
ObjectAdapterPtr
Ice::CommunicatorI::createObjectAdapter(const string& name)
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
-
- ObjectAdapterPtr adapter = _instance->objectAdapterFactory()->createObjectAdapter(name);
-
- return adapter;
+ return _instance->objectAdapterFactory()->createObjectAdapter(name);
}
ObjectAdapterPtr
@@ -227,163 +160,90 @@ Ice::CommunicatorI::createObjectAdapterWithEndpoints(const string& name, const s
void
Ice::CommunicatorI::addObjectFactory(const ObjectFactoryPtr& factory, const string& id)
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
_instance->servantFactoryManager()->add(factory, id);
}
void
Ice::CommunicatorI::removeObjectFactory(const string& id)
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
_instance->servantFactoryManager()->remove(id);
}
ObjectFactoryPtr
Ice::CommunicatorI::findObjectFactory(const string& id) const
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
return _instance->servantFactoryManager()->find(id);
}
PropertiesPtr
Ice::CommunicatorI::getProperties() const
{
- //
- // No check for destruction. It must be possible to access the
- // properties after destruction.
- //
return _instance->properties();
}
LoggerPtr
Ice::CommunicatorI::getLogger() const
{
- //
- // No check for destruction. It must be possible to access the
- // logger after destruction.
- //
return _instance->logger();
}
void
Ice::CommunicatorI::setLogger(const LoggerPtr& logger)
{
- //
- // No check for destruction. It must be possible to set the logger
- // after destruction (needed by logger plugins for example to
- // unset the logger).
- //
_instance->logger(logger);
}
StatsPtr
Ice::CommunicatorI::getStats() const
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
return _instance->stats();
}
void
Ice::CommunicatorI::setStats(const StatsPtr& stats)
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
_instance->stats(stats);
}
RouterPrx
Ice::CommunicatorI::getDefaultRouter() const
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
return _instance->referenceFactory()->getDefaultRouter();
}
void
Ice::CommunicatorI::setDefaultRouter(const RouterPrx& router)
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
_instance->referenceFactory()->setDefaultRouter(router);
}
LocatorPrx
Ice::CommunicatorI::getDefaultLocator() const
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
return _instance->referenceFactory()->getDefaultLocator();
}
void
Ice::CommunicatorI::setDefaultLocator(const LocatorPrx& locator)
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
_instance->referenceFactory()->setDefaultLocator(locator);
}
void
Ice::CommunicatorI::setDefaultContext(const Context& ctx)
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
_instance->setDefaultContext(ctx);
}
Ice::Context
Ice::CommunicatorI::getDefaultContext() const
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
return _instance->getDefaultContext();
}
PluginManagerPtr
Ice::CommunicatorI::getPluginManager() const
{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
return _instance->pluginManager();
}
@@ -393,20 +253,19 @@ Ice::CommunicatorI::flushBatchRequests()
_instance->flushBatchRequests();
}
-Ice::CommunicatorI::CommunicatorI(const PropertiesPtr& properties) :
- _destroyed(false)
+Ice::CommunicatorI::CommunicatorI(const PropertiesPtr& properties)
{
__setNoDelete(true);
try
{
- _instance = new Instance(this, properties);
+ const_cast<InstancePtr&>(_instance) = new Instance(this, properties);
//
// Keep a reference to the dynamic library list to ensure
// the libraries are not unloaded until this Communicator's
// destructor is invoked.
//
- _dynamicLibraryList = _instance->dynamicLibraryList();
+ const_cast<DynamicLibraryListPtr&>(_dynamicLibraryList) = _instance->dynamicLibraryList();
}
catch(...)
{
@@ -446,8 +305,7 @@ Ice::CommunicatorI::CommunicatorI(const PropertiesPtr& properties) :
Ice::CommunicatorI::~CommunicatorI()
{
- RecMutex::Lock sync(*this);
- if(!_destroyed)
+ if(!_instance->destroyed())
{
Warning out(_instance->logger());
out << "Ice::Communicator::destroy() has not been called";
@@ -476,7 +334,6 @@ Ice::CommunicatorI::finishSetup(int& argc, char* argv[])
}
catch(...)
{
- _destroyed = true;
_instance->destroy();
throw;
}